package com.bowenxu.struct;
public class Demo09 {
public static void main(String[] args) {
//关于break和continue;
//100-500的素数
int n = 100;
int t =0;
while (n<=500)
{
for (int i = 2; i < n; i++) {
if (n%i == 0){
//不是素数,下一个
n++;
continue;
}
}
//是素数,输出,然后下一个
System.out.print(n+"\t");
n++;
//8个一换行
t++;
if (t%8==0)
{
System.out.println();
}
}
}
}
14. 关于break和continue;
最新推荐文章于 2022-07-06 23:03:39 发布