human
Give me a code to fast Exponention using Bit Manipulation and the other steps required given the following:
Fast Exponention using Bit Manipulation | Function to return a ^ n.
Stores final answer.
Check if current LSB is set.
Right shift.
Driver code"
Solution in Python:
assistant
#Here is code to fast Exponention using Bit Manipulation and the other steps required.
 def powerOptimised ( a , n ) :
	ans = 1
	while ( n > 0 ) :
		last_bit = ( n & 1 )
		if ( last_bit ) :
			ans = ans * a
		a = a * a
		n = n >> 1
	return ans
if __name__ == ' _ _ main _ _ ' :
	a = 3
	n = 5
	print ( powerOptimised ( a , n ) )