X Tutup
Skip to content

Commit 7446579

Browse files
optimization
1 parent 98c94e1 commit 7446579

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Maths/PrimeCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static boolean isPrime(int n) {
2727
if (n < 2 || n % 2 == 0) {
2828
return false;
2929
}
30-
for (int i = 3; i <= Math.sqrt(n); i += 2) {
30+
for (int i = 3, limit = (int) Math.sqrt(n); i <= limit; i += 2) {
3131
if (n % i == 0) {
3232
return false;
3333
}

0 commit comments

Comments
 (0)
X Tutup