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 code
< ? php function perfectPowerOf2 ( $ n ) { $ per_pow = 1 ; while ( $ n > 0 ) { $ per_pow = $ per_pow << 1 ; $ n = $ n >> 1 ; } return $ per_pow ; } $ n = 128 ; echo " Perfect ▁ power ▁ of ▁ 2 ▁ greater ▁ than ▁ " . $ n . " : ▁ " . perfectPowerOf2 ( $ n ) ; ? >