A gym issues n locker tags, numbered 0 to n - 1. The i-th tag (0-indexed) is stamped with the value start + 2 * i, so consecutive tags always increase by exactly 2. To let staff quickly confirm that no tag was mis-stamped during printing, the front desk computes a single verification code: the bitwise XOR of every tag's stamped value.
A single line containing two space-separated integers n and start.
Print one integer: the bitwise XOR of the n values start, start + 2, start + 4, ..., start + 2 * (n - 1).
Example 1
Input
4 0
Expected
0
Explanation
With n=4 and start=0, the tags are 0, 2, 4, 6. XOR-ing them step by step: 0 XOR 2 = 2, 2 XOR 4 = 6, 6 XOR 6 = 0. The verification code is 0.
Example 2
Input
1 5
Expected
5
Explanation
With n=1 and start=5, there is only one tag, valued 5. The XOR of a single value is that value itself, so the verification code is 5.
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 →