Last active
May 16, 2023 12:01
-
-
Save lifeparticle/c2c04badfea84e8d84579d4f1d876f9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isPrime(int number) { | |
if (number < 2) | |
return false; | |
if (number == 2) | |
return true; | |
if(number % 2 == 0) | |
return false; | |
int sqrt = (int) Math.sqrt(number); | |
for (int i = 3; i <= sqrt; i+=2) { | |
if (number % i == 0) | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment