素数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数。
#include<stdio.h>
#include<math.h>
int main()
{
int i = 0;
int count = 0;
for (i = 101; i <= 199; i += 2)
{
int j = 0;
for (j = 3; j <= sqrt(i); j += 2)
{
if (i%j == 0)
{
break;
}
}
if (j >sqrt(i))
{
count++;
printf("%d ", i);
}
}
printf("count=%d\n", count);
system("pause");
}