Count pairs from a given range having equal Bitwise OR and XOR values | Javascript program for the above approach ; Function to find the value of ( x ^ y ) % MOD ; Initialize result ; Update x if it is more than or equal to MOD ; If y is odd , multiply x with result ; y must be even now , then update y / 2 ; Return ( x ^ y ) % MOD ; Function to count total pairs ; Finding 3 ^ N % 10 ^ 9 + 7 ; Driver Code ; Function Call
var MOD = 1000000007 ; function power ( x , y ) { var res = 1 ; x = x % MOD ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % MOD ; y = y >> 1 ; x = ( x * x ) % MOD ; } return res ; } function countPairs ( N ) { document . write ( power ( 3 , N ) ) ; } var N = 10 ; countPairs ( N ) ;