public class Solution { public static int countPrimes(int n) { int count = 0; for(int i = 2; i < n; i++){ if(IsPrime( i )){ count++; } } return count; } public static boolean IsPrime(int num) { for(int i=2;i<=num/2;i++){ if(num % i == 0){ return false; } } return true }
for
for (i=3; i<=ceiling(sqrt(num)); i=i+2) { ...}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)