Maximum Bitwise OR pair from a range | Function to return the maximum bitwise OR possible among all the possible pairs ; Check for every possible pair ; Maximum among all ( i , j ) pairs ; Driver code
function maxOR ( L , R ) { let maximum = Number . MIN_VALUE ; for ( let i = L ; i < R ; i ++ ) for ( let j = i + 1 ; j <= R ; j ++ ) maximum = Math . max ( maximum , ( i j ) ) ; return maximum ; } let L = 4 , R = 5 ; document . write ( maxOR ( L , R ) ) ;