204. Count Primes May 15, 2019 by omargamaleldeen 204. Count Primes class Solution { public int countPrimes(int n) { int count = 0; for (int i = 2; i < n; i++){ if (isPrime(i)) count++; } return count; } public boolean isPrime(int n){ for (int i = 2; i*i <= n; i++){ if ( n % i == 0) return false; } return true; } } Share this:TwitterFacebookLike this:Like Loading... Related