mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 02:04:31 +08:00
@ -27,7 +27,7 @@ public class PrimeCheck {
|
||||
if (n < 2 || n % 2 == 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 3; i <= Math.sqrt(n); i += 2) {
|
||||
for (int i = 3, limit = (int) Math.sqrt(n); i <= limit; i += 2) {
|
||||
if (n % i == 0) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user