8000 Add solution for Project Euler problem 188 by darkstar · Pull Request #2880 · TheAlgorithms/Python · GitHub
[go: up one dir, main page]

Skip to content

Add solution for Project Euler problem 188 #2880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some more doctest, and add type hints
  • Loading branch information
darkstar committed Oct 6, 2020
commit dcc9aa43e64e05e51027fe4db4c986ac1e6910ba
13 changes: 10 additions & 3 deletions project_euler/problem_188/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@


# small helper function for modular exponentiation
def modexpt(base, exponent, modulo_value):
def modexpt(base: int, exponent: int, modulo_value: int) -> int:
"""Returns the modular exponentiation, that is the value
of `base ** exponent % modulo_value`, without calculating
the actual number
the actual number.
>>> modexpt(2, 4, 10)
6
>>> modexpt(2, 1024, 100)
16
>>> modexpt(13, 65535, 7)
6
"""

if exponent == 1:
Expand All @@ -30,7 +36,8 @@ def modexpt(base, exponent, modulo_value):
else:
return (base * modexpt(base, exponent - 1, modulo_value)) % modulo_value

def solution(base=1777, height=1855, digits=8):

def solution(base: int = 1777, height: int = 1855, digits: int = 8) -> int:
"""Returns the last 8 digits of the hyperexponentiation of base by
height, i.e. the number base↑↑height:

Expand Down
0