diff --git a/maths/binary_exponentiation.py b/maths/binary_exponentiation.py index 05de939d1bde..7eeca89262a9 100644 --- a/maths/binary_exponentiation.py +++ b/maths/binary_exponentiation.py @@ -5,6 +5,12 @@ def binary_exponentiation(a: int, n: int) -> int: + """ + >>> binary_exponentiation(3, 5) + 243 + >>> binary_exponentiation(10, 3) + 1000 + """ if n == 0: return 1 @@ -17,6 +23,10 @@ def binary_exponentiation(a: int, n: int) -> int: if __name__ == "__main__": + import doctest + + doctest.testmod() + try: BASE = int(input("Enter Base : ").strip()) POWER = int(input("Enter Power : ").strip())