How to sum the numbers that are sum of fifth powers of their digits in Python

1 Answer

0 votes
lst = [i for i in range(1000, 1000000) if i == sum(int(d) ** 5 for d in str(i))]
 
print(lst)

result = sum(i for i in range(1000, 1000000) if i == sum(int(d) ** 5 for d in str(i)))
 
print(result)
 
 
 
 
'''
run:
 
[4150, 4151, 54748, 92727, 93084, 194979]
443839
 
'''

 



answered Dec 5, 2023 by avibootz
...