Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{ int firstnum,secondnum;
for(firstnum=1; firstnum<=499; firstnum++)
{
if(secondnum%firstnum)
{
secondnum=(firstnum*2)+1;
printf("%d ",secondnum);
}
else
{
printf("done");
}
}
system("PAUSE");
return 0;
}
need help, i cant seem to find out how to list all the prime numbers from 1-1000...im not sure how to test it to check if its a prime number this code prints 9 for example but 9 is not prime, can some1 help me fix it?? i also edited this to look like this, which is better:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{ int firstnum=1,secondnum=3;
if(!(secondnum%firstnum))
{
for(firstnum=1; firstnum<=499; firstnum++)
{
secondnum=(firstnum*2)+1;
printf("%d ",secondnum);
}
}
else
{
printf("Doesn't work MANG!!!");
}
system("PAUSE");
return 0;
}