human
Modular Exponentiation ( Power in Modular Arithmetic ) | Iterative Function to calculate ( x ^ y ) in O ( log y ).
Initialize result.
If y is odd , multiply x with result.
y must be even now y = y / 2.
Change x to x ^ 2"
How can the above be solved in Python?
assistant
#Here is code to modular Exponentiation ( Power in Modular Arithmetic ) and the other steps required.
 def power ( x , y ) :
	res = 1
	while ( y > 0 ) :
		if ( ( y & 1 ) != 0 ) :
			res = res * x
y = y >> 1
x = x * x
	return res