mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
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:
parent
9adb7ced16
commit
30c8d5573a
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue
Block a user