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
def TotalBitwiseORPair ( arr , N ) : NEW_LINE INDENT totalOR = 0 ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT totalOR |= arr [ i ] ; NEW_LINE DEDENT return totalOR ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 4 , 5 , 12 , 15 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE print ( TotalBitwiseORPair ( arr , N ) ) ; NEW_LINE DEDENT