Last active
December 17, 2015 04:08
-
-
Save charlesponti/5547992 to your computer and use it in GitHub Desktop.
Project Euler: Problem 16
This file contains 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
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