Bitwise OR of all unordered pairs from a given array | Function to find the bitwise OR of all possible pairs of the array ; Stores bitwise OR of all possible pairs of arr [ ] ; Traverse the array arr [ ] ; Update totalOR ; Return bitwise OR of all possible pairs of arr [ ] ; Driver Code
function TotalBitwiseORPair ( arr , N ) { let totalOR = 0 ; for ( let i = 0 ; i < N ; i ++ ) { totalOR |= arr [ i ] ; } return totalOR ; } let arr = [ 4 , 5 , 12 , 15 ] ; let N = arr . length ; document . write ( TotalBitwiseORPair ( arr , N ) ) ;