Skip to content

Instantly share code, notes, and snippets.

@adambom
Created June 29, 2012 21:02
Show Gist options
  • Save adambom/3020623 to your computer and use it in GitHub Desktop.
Save adambom/3020623 to your computer and use it in GitHub Desktop.
Is Prime Number??
function isDivisible(dividend, divisor) {
return dividend % divisor === 0;
}
function isPrime(n) {
var factor = 2;
n = Math.abs(n);
if (n <= 1) {
return true;
}
while (factor < n) {
if (isDivisible(n, factor)) {
return false;
}
factor += 1;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment