Generate an array of minimum sum whose XOR of same | Function to generate an array whose XOR with same - indexed elements of the given array is always a prime ; Traverse the array ; If current array element is 2 ; Print its XOR with 3 ; Otherwise ; Print its XOR with 2 ; Given array ; Size of the array ; Prints the required array
function minXOR ( Arr , N ) { for ( let i = 0 ; i < N ; i ++ ) { if ( Arr [ i ] == 2 ) { document . write ( ( Arr [ i ] ^ 3 ) + " " ) ; } else { document . write ( ( Arr [ i ] ^ 2 ) + " " ) ; } } } let Arr = [ 5 , 4 , 7 , 6 ] ; let N = Arr . length ; minXOR ( Arr , N ) ;