Created
December 16, 2023 22:15
-
-
Save mrandrewmills/80698a3b025d7fe092b434453a078d47 to your computer and use it in GitHub Desktop.
isPrime - function to test whether given number is a prime
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
function isPrime(thisNum){ | |
if ( thisNum <= 1 ) | |
return false; | |
for ( x = 2; x <= Math.sqrt(thisNum); x++ ){ | |
if ( thisNum % x == 0 ) | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment