XOR of Sum of every possible pair of an array | Function to find XOR of sum of all pairs ; Calculate xor of all the elements ; Return twice of xor value ; Drivers code
function findXor ( arr , n ) { let xoR = 0 ; for ( let i = 0 ; i < n ; i ++ ) { xoR = xoR ^ arr [ i ] ; } return xoR * 2 ; } let arr = [ 1 , 5 , 6 ] ; let n = arr . length ; document . write ( findXor ( arr , n ) ) ;