public class 第二版 {
public static void main(String[] args) {
int count = 0;//计数变量
int number = 2;
int squareRoot = 1;//这个变量记录平方根
while(number<10000){
boolean isPrime = true;
if(number == (squareRoot+1)*(squareRoot+1)) squareRoot++;
for(int i =2;i<= squareRoot;i++){
if(number % i == 0){
isPrime = false;
break;
}
}
if(isPrime){
count++;
System.out.println(number);
}
number++;
}
System.out.println("一共有"+count+"个素数");
}
}