Smallest perfect power of 2 greater than n ( without using arithmetic operators ) | JAVA Code for Smallest perfect power of 2 greater than n ; 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
import java . util . * ; class GFG { static int perfectPowerOf2 ( int n ) { int per_pow = 1 ; while ( n > 0 ) { per_pow = per_pow << 1 ; n = n >> 1 ; } return per_pow ; } public static void main ( String [ ] args ) { int n = 12 ; System . out . println ( " Perfect ▁ power ▁ of ▁ 2 ▁ greater ▁ than ▁ " + n + " : ▁ " + perfectPowerOf2 ( n ) ) ; } }