Created
April 8, 2015 16:16
-
-
Save trys/644f4a6eeb79129b80a7 to your computer and use it in GitHub Desktop.
Problem Seven
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
var resultCounter = 2, | |
primeFlag = false, | |
result = 0; | |
prime = 1; | |
for ( var i = 0; resultCounter < 10001; i++ ) { | |
primeFlag = false; | |
for ( var j = 2; j <= Math.sqrt( i ); j++ ) { | |
if ( i % j === 0 ) { | |
primeFlag = false; | |
break; | |
} | |
primeFlag = true; | |
} | |
if ( primeFlag ) { | |
resultCounter++; | |
result = i; | |
} | |
}; | |
document.write( result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment