Created
December 7, 2011 00:19
-
-
Save jakedobkin/1440758 to your computer and use it in GitHub Desktop.
Project Euler 40 in JS
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
| #!/usr/local/bin/node | |
| // calculate the decimal to 1MM places, but record certain values | |
| string = ""; | |
| for (i=1;i<=1000000;i++) | |
| { | |
| string += i.toString() | |
| } | |
| d1 = Number(string.slice(0,1)); | |
| d10 = Number(string.slice(9,10)); | |
| d100 = Number(string.slice(99,100)); | |
| d1000 = Number(string.slice(999,1000)); | |
| d10000 = Number(string.slice(9999,10000)); | |
| d100000 = Number(string.slice(99999,100000)); | |
| d1000000 = Number(string.slice(999999,1000000)); | |
| sum = d1 * d10 * d100 * d1000 * d10000 * d100000 * d1000000; | |
| console.log(sum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment