Project Euler Problem 048

Statement

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}$.

Solution

Straight-forward solution.

from functools import reduce
 
if __name__ == '__main__':
    limiter = 10 ** 10
    red_func = lambda x, y: (x % limiter + y % limiter) % limiter
    result = reduce(red_func, (i ** i for i in range(1, 1001)))
    print("The result is:", result)

The Python file is available for download here.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License