Largest set with bitwise OR equal to n | function to find the largest set with bitwise OR equal to n ; If the bitwise OR of n and i is equal to n , then include i in the set ; Driver Code
function setBitwiseORk ( n ) { var v = [ ] ; for ( var i = 0 ; i <= n ; i ++ ) { if ( ( i n ) == n ) v . push ( i ) ; } for ( var i = 0 ; i < v . length ; i ++ ) document . write ( v [ i ] + ' ' ) ; } var n = 5 ; setBitwiseORk ( n ) ;