/**
* Created with IntelliJ IDEA.
* Description:
* User: Wu Ruixi
* Date:2019/10/17
* Time:17:54
**/
public class Work2_3 {
public static void main(String[] args){
boolean bool;
for(int i = 3;i <100;i+=2){
bool = true;
for (int j = 3; j <= Math.sqrt(i); j++) {
if (i % j == 0) {
bool = false;
break;
}
}
if (bool){
System.out.print(i + " ");
}
}
}
}
打印 1 - 100 之间所有的素数
最新推荐文章于 2022-12-03 15:37:22 发布