public class PrimNumbers{
public static void main(String[] arg){
int count = 0;
for(int i=2;i<=100;i++){
boolean PrimNumber = true;
for(int j=2;j<i;j++){
if(i%j==0){
PrimNumber = false;
break;
}
}
if(PrimNumber){
count++;
System.out.print(i +" ");
if(count % 8 == 0){
System.out.println();
}
}
}
}
}
列举1~100所有素数,每隔八个数字换一行
最新推荐文章于 2023-01-15 17:43:29 发布