Multiplication with a power of 2 | Simple Java program to compute x * ( 2 ^ n ) ; Returns 2 raised to power n ; Driver program
import java . util . * ; class GFG { static long power2 ( long n ) { if ( n == 0 ) return 1 ; if ( n == 1 ) return 2 ; return power2 ( n / 2 ) * power2 ( n / 2 ) ; } static long multiply ( long x , long n ) { return x * power2 ( n ) ; } public static void main ( String [ ] args ) { long x = 70 , n = 2 ; System . out . println ( multiply ( x , n ) ) ; } }