to compute modular power iterative function to calculate xyp in olog y update x if it is more than or equal to p if y is odd multiply x with result y must be even now to compute modular power iterative function to calculate x y p in o log y initialize result update x if it is more than or equal to p if y is odd multiply x with result y must be even now y y 2
def power(x, y, p) : 
    res = 1     
  
    
    
    x = x % p  
  
    while (y > 0) : 
          
        
        
        if ((y & 1) == 1) : 
            res = (res * x) % p 
  
        
        y = y >> 1      
        x = (x * x) % p 
          
    return res