Created
November 12, 2011 17:56
-
-
Save djacobs/1360876 to your computer and use it in GitHub Desktop.
Euler 7 (for Jake)
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
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