public class Test {
public static void main(String[] args) {
int count = 0;
for(int i = 2;i<100;i++) {
int temp = (int) Math.sqrt(i);
int j = 2;
for(;j<=temp;j++) {
if(i%j==0){
break;
}
}
if(j>temp) {
count++;
System.out.print(i+" ");
if(count%5==0) {
System.out.println();
}
}
}
System.out.println();
System.out.println("101-200的素数个数为:"+count);
}
}
|