You are viewing a single comment's thread. Return to all comments →
Python 3 100% 1-liner
print(int(str(sum(pow(i, i, 10**10) for i in range(1, int(input())+1)))[-10:]))
The above is not the most computationally efficient.
If you don't count import statements againsed the "1-liner" qualifier, the following is better:
` from functools import reduce
print(reduce(lambda a, b: (a+b) % (10**10), [pow(i, i, 10**10) for i in range(1, int(input())+1)])) `
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Project Euler #48: Self powers
You are viewing a single comment's thread. Return to all comments →
Python 3 100% 1-liner
The above is not the most computationally efficient.
If you don't count import statements againsed the "1-liner" qualifier, the following is better:
` from functools import reduce
print(reduce(lambda a, b: (a+b) % (10**10), [pow(i, i, 10**10) for i in range(1, int(input())+1)])) `