题目:判断101-200之间有多少个素数,并输出所有素数。

 

 1 public class Algorithm_Game_02 {
 2     public static void main(String[] args) {
 3         for(int i = 101 ; i < 200 ; i++){
 4             boolean flag = true;
 5             for(int j = 2 ; j < Math.sqrt(i) ; j++){
 6                 if(i%j==0){
 7                     flag = false;
 8                     break;
 9                 }
10             }
11             if(flag)System.out.print(i+"=>");
12         } 
13     }
14 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-07-25
相关资源
相似解决方案