mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
Add typing to binary_exp_mod.py (#9469)
* Add typing to binary_exp_mod.py * Update binary_exp_mod.py * review changes
This commit is contained in:
parent
89a65a8617
commit
97154cfa35
|
@ -1,4 +1,4 @@
|
|||
def bin_exp_mod(a, n, b):
|
||||
def bin_exp_mod(a: int, n: int, b: int) -> int:
|
||||
"""
|
||||
>>> bin_exp_mod(3, 4, 5)
|
||||
1
|
||||
|
@ -13,7 +13,7 @@ def bin_exp_mod(a, n, b):
|
|||
if n % 2 == 1:
|
||||
return (bin_exp_mod(a, n - 1, b) * a) % b
|
||||
|
||||
r = bin_exp_mod(a, n / 2, b)
|
||||
r = bin_exp_mod(a, n // 2, b)
|
||||
return (r * r) % b
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user