Skip to main content
Code Review

Return to Revisions

3 of 3
Commonmark migration

Project Euler # 48 Self powers in Python

The series, \1ドル^1 + 2^2 + 3^3 + \ldots + 10^{10} = 10405071317\$.

Find the last ten digits of the series, \1ドル^1 + 2^2 + 3^3 + \ldots + 1000^{1000}\$.

def self_power(n):
 """returns sum of self powers up to n."""
 total = 0
 for i in range(1, n + 1):
 total += i ** i
 return str(total)[-10:]
if __name__ == '__main__':
 print(self_power(1000))
user203258
lang-py

AltStyle によって変換されたページ (->オリジナル) /