Maximum XOR | function to calculate maximum XOR value ; Return ( 2 ^ c - 1 ) ; Driver code
function maxXOR ( n , k ) { let c = ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ; return ( ( 1 << c ) - 1 ) ; } let n = 12 ; let k = 3 ; document . write ( maxXOR ( n , k ) ) ;