Skip to content

Instantly share code, notes, and snippets.

@wende
Created September 7, 2015 17:00
Show Gist options
  • Save wende/0562a5f61128013ea9ed to your computer and use it in GitHub Desktop.
Save wende/0562a5f61128013ea9ed to your computer and use it in GitHub Desktop.
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