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

 

你可能感兴趣的:(Java_利用continue来取质数)