Created
November 4, 2017 23:22
-
-
Save benaryorg/7b4aa86677000cac03ac1f779f975e4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#define xor_to(x) _xor_to((x),0,0) | |
long long _xor_to(long long to,long long cur,long long acc) | |
{ | |
cur+=1; | |
if(cur > to) | |
{ | |
return acc; | |
} | |
acc^=cur; | |
return _xor_to(to,cur,acc); | |
} | |
int main(int argc,char **argv) | |
{ | |
assert(argc == 2); | |
long long i=atoll(argv[1]); | |
printf("%llx\n",xor_to(i)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment