i had an assignment that ask me to find out the prime numbers from 2 to n numbers, and it must used the Sieve of Eratosthenes method to find that...(http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes), after i finished coding that refer to the wikipedia website, my program doesn't give the correct result, and i don't know what the problems are, can anyone please help me.... here's my code
bool isPrime[n];
for (i=1; i<n; i++)
isPrime[i]=true; //Initialization of all values to true
for (i=2; i<n; i++)
{
if (isPrime[i]=true)
{
for (j=i; j<n; j++)
{
if (j&i==0&&j!=i)
isPrime[j]=false; //Set all multiples of i to false.
}
}
}
Haven't run it in a compiler, but it should work..