1 package countPrimes204; 2 /* 3 * Description: 4 * Count the number of prime numbers less than a non-negative number, n. 5 */ 6 public class Solution { 7 //Time Limit Exceeded 8 /* 9 public static int countPrimes(int n) {10 int number=0;11 for (int i=0;i1;19 else if (n%2==0||n%3==0)20 return false;21 else{22 for(int i=2;i<=Math.sqrt(n);i++){23 if(n%i == 0)24 return false;25 }26 }27 return true;28 }29 */30 31 public static int countPrimes(int n) {32 //boolean default is false33 boolean[] IsPrime=new boolean[n];34 int numPrime=0;35 for (int i=2;i