Skip to content

Instantly share code, notes, and snippets.

@djacobs
Created November 12, 2011 17:56
Show Gist options
  • Save djacobs/1360876 to your computer and use it in GitHub Desktop.
Save djacobs/1360876 to your computer and use it in GitHub Desktop.
Euler 7 (for Jake)
primecount=1;
i=3;
while(primecount < 10001)
{
// console.log("looking at " + i);
isprime = true;
for (j=(Math.floor(Math.sqrt(i))); j > 1; j--) {
// for (j=2; j < (Math.floor(Math.sqrt(i)) + 1); j++ ) {
// console.log("looking at " + i + " " + j);
if (i%j==0) { isprime = false; }
}
if (isprime) {
lastprime=i;
primecount++;
//console.log(i + " is prime number " + primecount);
}
i+=2;
}
console.log(lastprime + " is the " + primecount + " prime number");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment