Count of N | Java program for the above approach ; Function to find the value of X to the power Y ; Stores the value of X ^ Y ; If y is odd , multiply x with result ; Update the value of y and x ; Return the result ; Function to count number of arrays having element over the range [ 0 , 2 ^ K - 1 ] with Bitwise AND value 0 having maximum possible sum ; Print the value of N ^ K ; Driver Code
public class GFG { static int power ( int x , int y ) { int res = 1 ; while ( y > 0 ) { if ( y % 2 != 0 ) res = res * x ; y = y >> 1 ; x = x * x ; } return res ; } static void countArrays ( int N , int K ) { System . out . println ( ( int ) ( power ( N , K ) ) ) ; } public static void main ( String args [ ] ) { int N = 5 , K = 6 ; countArrays ( N , K ) ; } }