Sum of Bitwise OR of every array element paired with all other array elements | Function to print required sum for every valid index i ; Store the required sum for current array element ; Generate all possible pairs ( arr [ i ] , arr [ j ] ) ; Update the value of req_sum ; Print required sum ; Given array ; Size of array ; Function call
def printORSumforEachElement ( arr , N ) : NEW_LINE INDENT for i in range ( 0 , N ) : NEW_LINE INDENT req_sum = 0 NEW_LINE for j in range ( 0 , N ) : NEW_LINE INDENT req_sum += ( arr [ i ] arr [ j ] ) NEW_LINE DEDENT print ( req_sum , end = " ▁ " ) NEW_LINE DEDENT DEDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE printORSumforEachElement ( arr , N ) NEW_LINE