Skip to content

Commit 780ebe0

Browse files
committed
Fix doctests and remove/improve redundant comments
1 parent c8747e4 commit 780ebe0

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

project_euler/problem_188/sol1.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,19 @@ def solution(base: int = 1777, height: int = 1855, digits: int = 8) -> int:
4949
Returns the last 8 digits of the hyperexponentiation of base by
5050
height, i.e. the number base↑↑height:
5151
52-
>>> solution()
53-
95962097
54-
>>> solution(3, 2)
52+
>>> solution(base=3, height=2)
5553
27
56-
>>> solution(3, 3)
54+
>>> solution(base=3, height=3)
5755
97484987
56+
>>> solution(base=123, height=456, digits=4)
57+
2547
5858
"""
5959

60-
# we calculate everything modulo 10^8, since we only care about the
61-
# last 8 digits
62-
modulo_value = 10 ** digits
63-
64-
# calculate base↑↑height (mod modulo_value) by repeated modular
65-
# exponentiation 'height' times
60+
# calculate base↑↑height by right-assiciative repeated modular
61+
# exponentiation
6662
result = base
6763
for i in range(1, height):
68-
result = _modexpt(base, result, modulo_value)
64+
result = _modexpt(base, result, 10 ** digits)
6965

7066
return result
7167

0 commit comments

Comments
 (0)