Update binary_exponentiation.py (#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>
This commit is contained in:
rtang09 2023-10-19 05:15:23 -07:00 committed by GitHub
parent 9adb7ced16
commit 30c8d5573a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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())