Maximum Bitwise OR pair from a range | C # implementation of the approach ; 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
using System ; class GFG { static int maxOR ( int L , int R ) { int maximum = int . MinValue ; for ( int i = L ; i < R ; i ++ ) for ( int j = i + 1 ; j <= R ; j ++ ) maximum = Math . Max ( maximum , ( i j ) ) ; return ; } public static void ( String [ ] args ) { int L = 4 , R = 5 ; Console . WriteLine ( maxOR ( L , R ) ) ; } }