Sum of Bitwise OR of every array element paired with all other array elements | Function to prlet 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 the required sum ; Given array ; Size of the array ; Function Call
function prletORSumforEachElement ( arr , N ) { for ( let i = 0 ; i < N ; i ++ ) { let req_sum = 0 ; for ( let j = 0 ; j < N ; j ++ ) { req_sum += ( arr [ i ] arr [ j ] ) ; } document . write ( req_sum + " " ) ; } } let arr = [ 1 , 2 , 3 , 4 ] ; let N = arr . length ; prletORSumforEachElement ( arr , N ) ;