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

1 Answer

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


 
 
'''
run:
 
[1634, 8208, 9474]
19316
 
'''

 



answered Dec 5, 2023 by avibootz
...