0
a method program to check whether a number is prime or not.
2 Réponses
+ 1
public static boolean isPrime(int n) {
if (n < 2) {
return false;
}
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
- 1
u can use it isProbablePrime () method if BigInteger class.