Compute the XOR of all integers from 0 to n inclusive: 0 XOR 1 XOR 2 XOR ... XOR n.
Input format
One line: a non-negative integer n.
Output format
One line: the XOR of 0..n.
Constraints
- 0 <= n <= 1000000000
Compute the XOR of all integers from 0 to n inclusive: 0 XOR 1 XOR 2 XOR ... XOR n.
One line: a non-negative integer n.
One line: the XOR of 0..n.
Example 1
Input
5
Expected
1
Explanation
0^1^2^3^4^5 = 1.
Example 2
Input
0
Expected
0
Explanation
The XOR of just 0 is 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →