learn-co-students / project-euler-power-digit-sum-onl01-seng-pt-041320

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project Euler Power Digit Sum

Write a method, power_digit_sum, that takes a base (x) and an exponent (n) as arguments and returns the sum of the digits of x raised to the power of n. It should work for arbitrarily large n (at least up to n = 1000).

For example, power_digit_sum(2, 4) would return 7:

  • 2 to the power of 4 is 16
  • 1 + 6 = 7

Run learn until you get all of the RSpec tests to pass.

Source

View Project Euler Power Digit Sum on Learn.co and start learning to code for free.

About


Languages

Language:Ruby 100.0%