Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
As
The sum of these numbers is
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
Let
def p30():
res = 0
for n in range(2, 354294):
ds, n_copy = 0, n
while n_copy > 0:
ds += (n_copy % 10) ** 5
n_copy //= 10
if ds == n:
res += n
return res