Python Binary Exponentiation || Python
In this we are going to see a basic program of binary exponentiation in Python Programming Language.



def BinExp(a, n):
    res = 1
    while(n>0):
        if n&1:
            res *= a
        a = a * a
        n = n >> 1
    return res

print(BinExp(2,12))

# Coded by Saahil


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post