Created
May 20, 2018 21:34
-
-
Save lopezm1/bf692c4a1c148c00db76b78327ffd8aa to your computer and use it in GitHub Desktop.
check if a number is a prime number
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 primeChecker(n) { | |
var divisor = 2; | |
var isPrime = true; | |
while(n > divisor){ | |
if(n % divisor === 0){ | |
isPrime = false; // not a PRIME!!! | |
} else { | |
divisor++; | |
} | |
} | |
console.log(isPrime); | |
} | |
primeChecker(137) | |
primeChecker(237) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment