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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…