@@ -0,0 +1,1408 @@
+/**%0A *%09Description:%0A *%0A *%09Count the number of prime numbers less than a non-negative number, n%0A *%0A *%09Author: matao%0A * %0A * %09Hint: %E5%9F%83%E6%8B%89%E6%89%98%E6%96%AF%E7%89%B9%E5%B0%BC%E7%AD%9B%E6%B3%95, %E8%8B%A5%E9%80%90%E4%B8%AA%E5%88%A4%E5%AE%9A%E5%88%99%E8%B6%85%E6%97%B6%0A */%0A%0A// %E5%B0%8F%E4%BA%8En%E7%9A%84%E6%89%80%E6%9C%89%E7%B4%A0%E6%95%B0%0Apublic class CountPrimes %7B%0A%09public static int countPrimes(int n) %7B%0A        if (n %3C= 2) %7B%0A        %09return 0;%0A        %7D%0A        %0A        boolean%5B%5D sieve = new boolean%5Bn%5D;%0A        for(int i = 2; i %3C n; i++) %7B%0A        %09sieve%5Bi%5D = true;%0A        %7D%0A        for(int i = 2; i %3C= (int)Math.sqrt(n); i++) %7B%0A        %09if(sieve%5Bi%5D) %7B%0A        %09%09for (int j = i; i * j %3C n; j++) %7B%0A        %09%09%09sieve%5Bi * j%5D = false;%0A        %09%09%7D%0A        %09%7D%0A        %7D%0A%0A        int count = 0;%0A        for(int i = 2; i %3C n; i++) %7B%0A        %09if (sieve%5Bi%5D) %7B%0A        %09%09++count;%0A        %09%7D%0A        %7D%0A        return count;%0A    %7D%0A    %0A    // public static boolean isPrime(int x) %7B%0A    //     if(x == 0 %7C%7C x == 1)%0A    //         return false;%0A    //     if(x == 2)%0A    //         return true;%0A    //     for(int i = 2; i %3C= (int)Math.sqrt(x); i++) %7B%0A    //         if(x %25 i == 0)%0A    //             return false;%0A    //     %7D%0A    //     return true;%0A    // %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09int count1 = countPrimes(2);%0A    %09int count2 = countPrimes(999983);%0A    %09int count3 = countPrimes(30);%0A    %09int count4 = countPrimes(65535);%0A    %09System.out.println(count1);%0A    %09System.out.println(count2);%0A    %09System.out.println(count3);%0A    %09System.out.println(count4);%0A    %7D%0A%7D

add Count Primes solution