Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 8, 2015 16:16
Show Gist options
  • Save trys/644f4a6eeb79129b80a7 to your computer and use it in GitHub Desktop.
Save trys/644f4a6eeb79129b80a7 to your computer and use it in GitHub Desktop.
Problem Seven
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