Find the value of N XOR 'ed to itself K times | Java implementation of the approach ; Function to return n ^ n ^ ... k times ; Find the result ; Driver code
class GFG { static int xorK ( int n , int k ) { int res = n ; for ( int i = 1 ; i < k ; i ++ ) res = ( res ^ n ) ; return n ; } public static void main ( String [ ] args ) { int n = 123 , k = 3 ; System . out . print ( xorK ( n , k ) ) ; } }