Created
April 8, 2015 16:43
-
-
Save trys/16bd20c9e2ea79258eae to your computer and use it in GitHub Desktop.
Problem Ten
This file contains hidden or 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 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