Created
September 7, 2015 17:00
-
-
Save wende/0562a5f61128013ea9ed to your computer and use it in GitHub Desktop.
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 firstNPrime(n){ | |
var i = 1, j = 0, k = 0; | |
var result = [] | |
while(++i && result.length != n){ | |
k = i | |
j = 0 | |
while(--k){ | |
if(i % k == 0) j++ | |
} | |
if(j == 1)result.push(i) | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment