Created
May 10, 2012 20:34
-
-
Save qwertypants/2655710 to your computer and use it in GitHub Desktop.
Generate prime numbres
This file contains hidden or 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 genPrimes(min, max){ | |
var isPrime, primes = []; | |
for (var i = min; i <= max; i++) { | |
isPrime = true; | |
for (var j = min; j * j <= i; j++) { | |
if (i % j === 0) { | |
isPrime = false; | |
break; | |
} | |
} | |
if (isPrime) { | |
primes.push(i); | |
} | |
} | |
return primes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment