public class zhishu{
public static void main(String[] args){
printZuiXiaoZhishu(3);
}
public static void printZuiXiaoZhishu(int n){
/*while(true){
n++;
boolean flag = isZhiShu(n);
if(flag){
System.out.println(n);
break;
}
*/
while(!isZhiShu(++n)){
}
System.out.println(n);
}
public static boolean isZhiShu(int num){
for(int i = 2;i<num; i++){
if(num%i==0){
return false;
}
}
return true;
}
}
用Java输出大于某个正整数n的最小的质数
最新推荐文章于 2024-08-31 10:44:02 发布