count the number of prime numbers in an array
public static int solution(int[] A) { int count = 0; for (int i = 0; i < A.Length; i++) { if (isPrime(A[i])) { count++; } } return count; } private static bool isPrime(int n) { //check if n is a multiple of 2 if (n % 2 == 0) return false; //if not, then just check the odds for (int i = 3; i * i <= n; i += 2) { if (n % i == 0) return false; } return true; }