Back to Project Euler

Previous Problem Next Problem

Problem 48: Self Powers

The series, \(1^1 + 2^2 + 3^3 + \cdots + 10^{10} = 10405071317\).

Find the last ten digits of the series, \(1^1 + 2^2 + 3^3 + \cdots + 1000^{1000}\).

Solution

Conveniently, Python has a built-in function for modular exponentiation.

Python Code

p48 = lambda n=1000: sum(pow(x, x, 10**10) for x in range(1,n+1)) % 10**10

Previous Problem Next Problem

Back to Project Euler