Java_利用continue来取质数

 1 package first_1;
 2 
 3 public class primeNumberTest2 {
 4     public static void main(String[] args) {
 5         
 6         
 7         int count = 0;
 8         label:for (int i = 2; i < 100000; i++) {
 9             for (int j = 2; j <= Math.sqrt(i); j++) {
10                 if (i % j == 0) {
11                     continue label;
12                 }
13             
14             }
15             count++;
16         
17         }
18         System.out.println("质数的个数为:" + count);
19 
20     }
21 }
View Code

 

posted @ 2020-07-13 19:18  I_code_rookie  阅读(196)  评论(0编辑  收藏  举报