199 is also a prime number.
[Plain]
# Include <stdio. h>
Int main ()
{
Int I;
Int j;
Int k;
Int flag = 0;
Int num;
Printf ("% 3d is a prime number. \ n", 2); // 2 is the only one with an even number and a prime number.
For (I = 1; 2 * I-1 <= 200; I ++) // even numbers are not prime numbers, so exclude
{
Num = 2 * I-1;
If (num> 2)
{
Flag = 1; // flag
For (j = 2; j <num/2; j ++)
{
If (num % j = 0) // check whether it is a prime number, not flag = 0
{
Flag = 0;
Break;
}
}
If (flag = 1)
{
Printf ("% 3d is prime number. \ n", num );
}
}
}
Return 0;
}
# Include <stdio. h>
Int main ()
{
Int I;
Int j;
Int k;
Int flag = 0;
Int num;
Printf ("% 3d is a prime number. \ n", 2); // 2 is the only one with an even number and a prime number.
For (I = 1; 2 * I-1 <= 200; I ++) // even numbers are not prime numbers, so exclude
{
Num = 2 * I-1;
If (num> 2)
{
Flag = 1; // flag
For (j = 2; j <num/2; j ++)
{
If (num % j = 0) // check whether it is a prime number, not flag = 0
{
Flag = 0;
Break;
}
}
If (flag = 1)
{
Printf ("% 3d is prime number. \ n", num );
}
}
}
Return 0;
}
[Plain] view plaincopyprint? <PRE> </PRE>
<PRE> </PRE>
<PRE> </PRE>
<PRE> </PRE>
<PRE> </PRE>