Construct an array whose Prefix XOR array starting from X is an N | Function to print the required array ; Iteratie from 1 to N ; Print the i - th element ; Update prev_xor to i ; Given Input ; Function Call
function GenerateArray ( N , X ) { let prev_xor = X ; for ( let i = 1 ; i <= N ; i ++ ) { document . write ( ( i ^ prev_xor ) ) ; if ( i != N ) { document . write ( " " ) ; } prev_xor = i ; } } let N = 4 , X = 3 ; document . write ( " " ) ; GenerateArray ( N , X ) ;