25 lines
484 B
Python

#!/usr/bin/env python3
# The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
#
# Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
from projecteuler import timing
@timing
def p048() -> None:
_sum = 0
# Simply calculate the sum of the powers
for i in range(1, 1001):
power = i ** i
_sum = _sum + power
print('Project Euler, Problem 48')
print(f'Answer: {str(_sum)[-10:]}')
if __name__ == '__main__':
p048()