zzy060505

for循环找出1-100中所以的素数

package 控制语句;

public class for循环找出一到一百中所有的素数 {
public static void main(String[] args) {
        int count = 0;
for (int i =2;i <=100;i++){

//这里的这段代码只判断i是否为素数
boolean isSushu = true;
for (int j=2;j<i;j++){
if (i % j == 0){
isSushu = false;
break;
}
}
if (isSushu){
System.out.print(i+" ");
count++;
if (count == 8){
System.out.println();
//归0
count = 0;
}
}
}


}
}
发表于 2021-05-10 17:49  Relievedᴗz  阅读(1287)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-10-21
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-10-21
相关资源
相似解决方案