Refactored all solutions
This commit is contained in:
@@ -25,13 +25,14 @@ class Prime {
|
||||
if (n < 2) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 2; i <= (int) Math.sqrt(n); i++) {
|
||||
int sqrt = (int) Math.sqrt(n);
|
||||
for (int i = 2; i <= sqrt; i++) {
|
||||
if (n % i == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Solution {
|
||||
|
||||
Reference in New Issue
Block a user