Python/project_euler/problem_048/sol1.py

26 lines
461 B
Python
Raw Normal View History

"""
2018-10-19 12:48:28 +00:00
Self Powers
Problem 48
2020-09-20 19:33:26 +00:00
The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
2018-10-19 12:48:28 +00:00
2020-09-20 19:33:26 +00:00
Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
"""
2018-10-19 12:48:28 +00:00
def solution():
2020-09-20 19:33:26 +00:00
"""
Returns the last 10 digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
2018-10-19 12:48:28 +00:00
>>> solution()
'9110846700'
"""
total = 0
for i in range(1, 1001):
total += i**i
return str(total)[-10:]
if __name__ == "__main__":
print(solution())