XOR of 1..N
Compute 1 ⊕ 2 ⊕ 3 ⊕ … ⊕ N (bitwise XOR).
Input: one integer N.
Output: the XOR of all integers from 1 to N.
Constraints:
- 1 ≤ N ≤ 1018
Sample Tests
Input 1
7
Output 1
0
Input 2
3
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.