project_euler.problem_119.sol1

Problem 119: https://projecteuler.net/problem=119

Name: Digit power sum

The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 8^3 = 512. Another example of a number with this property is 614656 = 28^4. We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum. You are given that a2 = 512 and a10 = 614656. Find a30

Functions

digit_sum(→ int)

Returns the sum of the digits of the number.

solution(→ int)

Returns the value of 30th digit power sum.

Module Contents

project_euler.problem_119.sol1.digit_sum(n: int) int

Returns the sum of the digits of the number. >>> digit_sum(123) 6 >>> digit_sum(456) 15 >>> digit_sum(78910) 25

project_euler.problem_119.sol1.solution(n: int = 30) int

Returns the value of 30th digit power sum. >>> solution(2) 512 >>> solution(5) 5832 >>> solution(10) 614656