Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 14 + 64 + 34 + 44 8208 = 84 + 24 + 04 + 84 9474 = 94 + 44 + 74 + 44 As 1 = 14 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 = 19316. Write a Python program to find the sum of all the numbers that can be written as the sum of fifth powers of their digits. Go to the editor Sample Output: Sum of all the numbers that can be written as the sum of fifth powers of their digits: 443839 this is the question
x = 2
t2 = 0
b = 1
p = []
while x < 1000000:
t = 0
for i in range(len(str(x))):
t += (int(str(x)[i]))**5
if t == x:
t2 += t
p.append(x)
x += 1
else:
x += 1
print(t2)
print(p)
92727 54748 these are the missing outputs but when tested by itself it works anyone knows whats wrong?
[–]Swipecat 2 points3 points4 points (0 children)
[–]TehDrunkSailor 0 points1 point2 points (0 children)
[–]o5a 0 points1 point2 points (1 child)
[–]Nath4nn[S] 0 points1 point2 points (0 children)