#include <stdio.h>
#include <math.h>
int main()
{
int i,j,z=0,nosu=0;
for(i=2;i<100;i++)
{
for(j=2;j<=sqrt(i);j++)
{
if(i%j == 0)
{
nosu=1;
break;
}
}
//是素数
if(!nosu)
{
if(z%5==0 && z!=0)
{
printf("\n");
}
printf("%d\t",i); //打印
z++;
}else
{
nosu=0;
}
}
printf("\n");
return 0;
}
结果
2 3 5 7 11
13 17 19 23 29
31 37 41 43 47
53 59 61 67 71
73 79 83 89 97