标签:
1 public class Solution 2 { 3 public static void main(String[] args) 4 { 5 int count = 0; 6 7 for(int i = 1; i < 10000; i++) 8 if(isPrime(i)) 9 count++; 10 11 System.out.println("The count of the prime number smaller than 10000 is: " + count); 12 } 13 14 public static boolean isPrime(int number) 15 { 16 if(number <= 1) 17 return false; 18 else if(number == 2) 19 return true; 20 else 21 { 22 for(int i = 2; i < number; i++) 23 if(number % i == 0) 24 return false; 25 return true; 26 } 27 } 28 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5790927.html