euler/python/e030.py

14 lines
415 B
Python
Raw Normal View History

2019-07-16 18:51:07 +02:00
def euler_030():
fifth_power_lookup = {str(i): i**5 for i in range(0, 10)}
def is_number_sum_of_fiths_powers_of_digits(n):
return n == sum([fifth_power_lookup[d] for d in str(n)])
return sum([i for i in range(2, 1000000)
if is_number_sum_of_fiths_powers_of_digits(i)])
if __name__ == "__main__":
print("e030.py: {}".format(euler_030()))
assert(euler_030() == 443839)