Created
June 29, 2012 21:02
-
-
Save adambom/3020623 to your computer and use it in GitHub Desktop.
Is 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 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