Sum of XOR of sum of all pairs in an array | Javascript program to find XOR of pair sums . ; Driver code
function xorPairSum ( ar , n ) { var sum = 0 ; for ( i = 0 ; i < n ; i ++ ) sum = sum ^ ar [ i ] ; return 2 * sum ; } var arr = [ 1 , 2 , 3 ] ; var n = arr . length ; document . write ( xorPairSum ( arr , n ) ) ;