public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < 10000; i++) if(isPrime(i)) count++; System.out.println("The count of the prime number smaller than 10000 is: " + count); } public static boolean isPrime(int number) { if(number <= 1) return false; else if(number == 2) return true; else { for(int i = 2; i < number; i++) if(number % i == 0) return false; return true; } } }
相关文章
- 01-20HW5.10