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

题目:判断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 }
原文地址:https://www.cnblogs.com/elleniou/p/3283046.html