# Thread: I dont know what is wrong???

1. ## I dont know what is wrong???

hi guys , i have a problem with my code i dont know why the compiler did not work it it have no error before i run it but after it give me error noting in screen

Code:
```/* This program finds an integer between 1 and 10000 that has
the largest number of divisors.  It prints out the maximum
number of divisors and an integer that has that many divisors.    */

#include <stdio.h>
void main()
{
int i ;

// One of the integers whose divisors we have to count.

int max ;

// Maximum number of divisors seen so far.

int nmax;

// A value of N that had the given number of divisors.

max=1;

nmax=1;

/* Process all the remaining values of N from 2 to 10000, and
update the values of maxDivisors and numWithMax whenever we
find a value of N that has more divisors than the current value
of maxDivisors.        */

for(i=2;2<=10000;i++)
{
int j;

// A number to be tested to see if its a divisor of N.

int ndivisor;

// Number of divisors of N.

for(j=1;j<=i;j++)
{
if(i%j==0)
ndivisor++;

// Count the divisors of N.
}
if(ndivisor>max)
{
max=ndivisor;
nmax=i;
}
}
printf("The maximum number of divisors is %d ",max);
printf("number of divisors it have is %d",nmax);
}```

2. Try setting ndivisor to 0 before you start counting.

3. Check the condition of the outher for loop.
Kurt

4. Originally Posted by ZuK
Check the condition of the outher for loop.
Kurt
thanks very much it work now