这是我的,你可以看一下
class HomeWork4 {
public static void main(String[] args) {
int j;
int count = 0;
for (int i = 2;i <= 100 ;i++ ) {
j = 2;
while (i % j != 0) {
j++;
}
if (j == i) {
System.out.print(i+" ");
count++;
if (count % 5 == 0) {
System.out.println();
}
}
}System.out.println("100以内的素数个数为:"+count);
}} |