mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Update binary_exponentiation.py
This commit is contained in:
parent
c850227bee
commit
2b102bb260
@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
|
|
||||||
def binary_exponentiation(a: int, n: int) -> int:
|
def binary_exponentiation(a: int, n: int) -> int:
|
||||||
|
'''
|
||||||
|
>>> binary_exponentiation(3, 5)
|
||||||
|
243
|
||||||
|
>>> binary_exponentiation(10, 3)
|
||||||
|
1000
|
||||||
|
'''
|
||||||
if n == 0:
|
if n == 0:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -17,6 +23,9 @@ def binary_exponentiation(a: int, n: int) -> int:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
import doctest
|
||||||
|
doctest.testmod()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
BASE = int(input("Enter Base : ").strip())
|
BASE = int(input("Enter Base : ").strip())
|
||||||
POWER = int(input("Enter Power : ").strip())
|
POWER = int(input("Enter Power : ").strip())
|
||||||
|
Loading…
Reference in New Issue
Block a user