Find the value of N XOR 'ed to itself K times | Function to return n ^ n ^ ... k times ; If k is odd the answer is the number itself ; Else the answer is 0 ; Driver code
function xorK ( n , k ) { if ( k % 2 == 1 ) return n ; return 0 ; } let n = 123 , k = 3 ; document . write ( xorK ( n , k ) ) ;