We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 98c94e1 commit 7446579Copy full SHA for 7446579
Maths/PrimeCheck.java
@@ -27,7 +27,7 @@ public static boolean isPrime(int n) {
27
if (n < 2 || n % 2 == 0) {
28
return false;
29
}
30
- for (int i = 3; i <= Math.sqrt(n); i += 2) {
+ for (int i = 3, limit = (int) Math.sqrt(n); i <= limit; i += 2) {
31
if (n % i == 0) {
32
33
0 commit comments