Skip to content

Instantly share code, notes, and snippets.

@nickedes
Created September 27, 2015 17:54
Show Gist options
  • Save nickedes/ccfe26d5e334c14005fc to your computer and use it in GitHub Desktop.
Save nickedes/ccfe26d5e334c14005fc to your computer and use it in GitHub Desktop.
# XOR of first N natural no.s
N = int(input())
if (N % 2) == 0:
if (N % 4) == 0:
r = N
else:
r = N+1
else:
if (N % 4) == 1:
r = 1
else:
r = 0
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment