Skip to content

Instantly share code, notes, and snippets.

@qwertypants
Created May 10, 2012 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwertypants/2655710 to your computer and use it in GitHub Desktop.
Save qwertypants/2655710 to your computer and use it in GitHub Desktop.
Generate prime numbres
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