Skip to content

Instantly share code, notes, and snippets.

@johana-star
Created May 29, 2011 18:36
Show Gist options
  • Save johana-star/998024 to your computer and use it in GitHub Desktop.
Save johana-star/998024 to your computer and use it in GitHub Desktop.
Euler Project Problem #040
# 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