Skip to content

Instantly share code, notes, and snippets.

@mrandrewmills
Created December 16, 2023 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrandrewmills/80698a3b025d7fe092b434453a078d47 to your computer and use it in GitHub Desktop.
Save mrandrewmills/80698a3b025d7fe092b434453a078d47 to your computer and use it in GitHub Desktop.
isPrime - function to test whether given number is a prime
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