Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Last active December 17, 2015 04:08
Show Gist options
  • Save charlesponti/5547992 to your computer and use it in GitHub Desktop.
Save charlesponti/5547992 to your computer and use it in GitHub Desktop.
Project Euler: Problem 16
def power_sum(base, expo)
num = base
2.upto(expo) { |i| num *= base }
sum = 0
num.to_s.split(//).each { |i| sum += i.to_i }
p sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment