MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_048/sol1.py:11–21  ·  view source on GitHub ↗

Returns the last 10 digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. >>> solution() '9110846700'

()

Source from the content-addressed store, hash-verified

9
10
11def solution():
12 """
13 Returns the last 10 digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
14
15 >>> solution()
16 '9110846700'
17 """
18 total = 0
19 for i in range(1, 1001):
20 total += i**i
21 return str(total)[-10:]
22
23
24if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected