计算101-200之间的素数个数,并输出

来源:互联网 发布:mac ape 打开格式 编辑:程序博客网 时间:2024/05/21 08:43

public class Test01{

public static void main(String[] args){

int count=0;

for(int i=101;i<=200;i++){

for(int j=2;j<=(int)Math.sqrt(i);j++){

if(i%j==0){

break;

}

if(j==(int)Math.sqrt){

count++;

System.out.println(i);

}

}

}

System.out.println("素数的个数是:"+count);

}

}

0 0