Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 8, 2015 16:43
Show Gist options
  • Save trys/16bd20c9e2ea79258eae to your computer and use it in GitHub Desktop.
Save trys/16bd20c9e2ea79258eae to your computer and use it in GitHub Desktop.
Problem Ten
var primeFlag = false,
result = 5;
for ( var i = 0; i <= 2000000; i++ ) {
primeFlag = false;
for ( var j = 2; j <= Math.sqrt( i ); j++ ) {
if ( i % j === 0 ) {
primeFlag = false;
break;
}
primeFlag = true;
}
if ( primeFlag ) {
result += i;
}
};
document.write( result );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment