mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Rename Project Euler directories and other dependent changes (#3300)
* Rename all Project Euler directories: Reason: The change was done to maintain consistency throughout the directory and to keep all directories in sorted order. Due to the above change, some config files had to be modified: 'problem_22` -> `problem_022` * Update scripts to pad zeroes in PE directories
This commit is contained in:
0
project_euler/problem_048/__init__.py
Normal file
0
project_euler/problem_048/__init__.py
Normal file
25
project_euler/problem_048/sol1.py
Normal file
25
project_euler/problem_048/sol1.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Self Powers
|
||||
Problem 48
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
|
||||
def solution():
|
||||
"""
|
||||
Returns the last 10 digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
|
||||
|
||||
>>> solution()
|
||||
'9110846700'
|
||||
"""
|
||||
total = 0
|
||||
for i in range(1, 1001):
|
||||
total += i ** i
|
||||
return str(total)[-10:]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(solution())
|
||||
Reference in New Issue
Block a user