This is my isPrime
method:
private static boolean isPrime(int num) {
if (num % 2 == 0) return false;
for (int i = 3; i * i < num; i += 2)
if (num % i == 0) return false;
return true;
}
I put isPrime(9)
and it returns true
. What is wrong with the method?