/*
* .编程打印所有的3位质数,质数特点:只能被1和其本身整除
*/
public class ZhiShuDemo {
public static void main(String[] args) {
//定义统计变量统计count出现次数
int count=0;
//100-999,次数已知用for
for (int i = 100; i < 1000; i++) {
//不确定循环次数,用while。每次都从2开始。判断j的值输出素数
int j = 2;
while (i % j != 0)
j++;
//如果j>i的正方根,输出
if (j > Math.sqrt(i)) {
System.out.println(i);
count++;
}
}
System.out.println("三位数的指数一共有:"+count+"个.");
}
}