-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path30.py
17 lines (14 loc) · 1.39 KB
/
30.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def pow_sum(n, e):
res = 0
while (n > 0):
res += (n % 10)**e
n //= 10
return res
ans_list = []
for i in range(2, 360000):
if i == pow_sum(i, 5):
ans_list.append(i)
print(ans_list, sum(ans_list))
#########################################################################################################################################################################################################################################################################################################################################################################################################
# Print the results for 9**5*i where i ranges from 1 to 10 and check the results. You will notice that the value 9**5*6 = 354294 is much smaller than 999999 (9 occurs six times), that is, after this point there are no numbers that will have the sum of the fifth power of their digits to the number itself, because the number of digits(i * '9') will grow much larger than the 9**5*i function. #
#########################################################################################################################################################################################################################################################################################################################################################################################################