Merge pull request #950 from shellhub/master

optimization
This commit is contained in:
Yang Libin
2019-10-06 11:16:50 +08:00
committed by GitHub

View File

@ -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;
}