Skip to content

Instantly share code, notes, and snippets.

@lopezm1
Created May 20, 2018 21:34
Show Gist options
  • Save lopezm1/bf692c4a1c148c00db76b78327ffd8aa to your computer and use it in GitHub Desktop.
Save lopezm1/bf692c4a1c148c00db76b78327ffd8aa to your computer and use it in GitHub Desktop.
check if a number is a prime number
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