Created
May 29, 2011 18:36
-
-
Save johana-star/998024 to your computer and use it in GitHub Desktop.
Euler Project Problem #040
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
# Solution to Project Euler's fortieth problem | |
# http://projecteuler.net/index.php?section=problems&id=40 | |
# Find the product of the first, tenth, hundredth, thousandth, ten-thousandth, hundred-thousandth, and millionth digit of the irrational fraction created by concatenating the positive integers. | |
count = 0 | |
ceiling = 1000000 | |
number = "" | |
until number.length > ceiling do | |
count += 1 | |
number.concat count.to_s | |
end | |
p number.slice(0).to_i * number.slice(9).to_i * number.slice(99).to_i * number.slice(999).to_i * number.slice(9999).to_i * number.slice(99999).to_i * number.slice(999999).to_i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment