Skip to content

Commit 30c8d55

Browse files
Update binary_exponentiation.py (TheAlgorithms#10253)
* Update binary_exponentiation.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9adb7ce commit 30c8d55

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

maths/binary_exponentiation.py

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66

77
def binary_exponentiation(a: int, n: int) -> int:
8+
"""
9+
>>> binary_exponentiation(3, 5)
10+
243
11+
>>> binary_exponentiation(10, 3)
12+
1000
13+
"""
814
if n == 0:
915
return 1
1016

@@ -17,6 +23,10 @@ def binary_exponentiation(a: int, n: int) -> int:
1723

1824

1925
if __name__ == "__main__":
26+
import doctest
27+
28+
doctest.testmod()
29+
2030
try:
2131
BASE = int(input("Enter Base : ").strip())
2232
POWER = int(input("Enter Power : ").strip())

0 commit comments

Comments
 (0)