Skip to content

Instantly share code, notes, and snippets.

@joecannatti
Created December 28, 2011 03:22
Show Gist options
  • Save joecannatti/1526033 to your computer and use it in GitHub Desktop.
Save joecannatti/1526033 to your computer and use it in GitHub Desktop.
euler34
#!/usr/bin/env ruby
total = 0
(3..100000).each do |num|
res = num.to_s.chars.map { |d| d.to_i > 0 ? d.to_i.downto(1).inject(:*) : 1 }.inject(:+)
total += num if res == num
end
p total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment