class Workt2 {
public static void main(String[] args) {
int count = 0;
for (int i = 2;i <= 100 ;i ++ ) {
int j = 2;
for (j = 2;j < i / 2 ;j ++ ) {
if (i % j == 0) {
break ;
} //如果能被比自己小的数整除,就跳出取余的循环
}
if (j == i / 2 ) {
System.out.print(i + " ");
count ++;
if (count % 5 == 0 ) {
System.out.println();
}
} //如果取余循环完了,就证明这个数是素数,输出,计数器+1
}
}
} |
|