Created
May 6, 2014 21:01
-
-
Save chee/fcbf4e2cd66d65341c64 to your computer and use it in GitHub Desktop.
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 getPrimes(max) { | |
return Array.apply(null, {length: max + 1}).map(function(){}.call, Number).filter(function(n) { | |
if (n < 2) return false; | |
for (var i = 2; i <= Math.sqrt(n); i++) { | |
if (n % i == 0) return false; | |
} | |
return true; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment