human
Give me a code to smallest perfect power of 2 greater than n ( without using arithmetic operators ) and the other steps required given the following:
Smallest perfect power of 2 greater than n ( without using arithmetic operators ) | Function to find smallest perfect power of 2 greater than n.
To store perfect power of 2.
bitwise left shift by 1.
bitwise right shift by 1.
Required perfect power of 2.
Driver program to test above"
Solution in Python:
assistant
#Here is code to smallest perfect power of 2 greater than n ( without using arithmetic operators ) and the other steps required.
 def perfectPowerOf2 ( n ) :
	per_pow = 1
	while n > 0 :
		per_pow = per_pow << 1
		n = n >> 1
	return per_pow
n = 128
print ( " Perfect ▁ power ▁ of ▁ 2 ▁ greater ▁ than " , n , " : " , perfectPowerOf2 ( n ) )