The following equation is 1 ** 1 + 2 ** 2 + 3 ** 3 + ... + 10 ** 10 = 10405071317
.
Now, find the last 10 digits of 1 ** 1 + 2 ** 2 + 3 ** 3 + ... + 1000 ** 1000
.
http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2048
End with generator and sum. It seems to be the last 10 digits, so I tried to divide it by 10 ** 10
on the way, but it is a mystery how much it will change.
# coding: utf-8
def main():
MAX = 1000
DIV = 10**10
print sum((i**i) % DIV for i in range(1,MAX+1)) % DIV
main()
Recommended Posts