Okay..this is my new program..as lousy as it is..but it works!!!
Code:
#include<stdio.h>
main()
{
int number, i;
for (number=1;number<=300;number++)
{
for (i=2; (i<number) || (i==number) ; i++)
{
if (i==number)
{
printf ("\n%d", number);
}
if (number%5==0)
{
break;
}
if (number%i == 0 )
{
break;
}
else
{
printf ("\n%d", number);
break;
}
}
}
}
@mako
if you start with number on 2, and with i on 2. Then it should be obvious that number%i is 0...
and you don't need the second break...
Yeah man..I could figure that out.
If I don't put the second break...it gives me a hell lotta duplicates...
@Prelude
Not yet done with the functions man...I suppose they will make things easier...hehe
@Salem
Look up the definition of Prime (again).
In fact, look at Eratosthenes sieve (google for it).
Yeah man..I know the definition of Prime..
I put int quite a lotta effort into this so called "easy" program..but still did not get the wanted result, so I seeked help.
Well..the Eratosthenes sieve thing was great!
Anybody suggesting an improvement in the program ??