#include <iostream>
using namespace std;
int sequence(int n)
{
int a;
switch(n%4)
{
case 0:
a=n;
break;
case 1:
a=1;
break;
case 2:
a=n+1;
break;
case 3:
a=0;
break;
}
return a;
}
//main function
int main(){
int n;
//input number
cin>>n;
int result=sequence(n);
cout<<result<<endl;
return 0;
}
C++ program:
Output
Explanation:
Number X-OR 1 to N modulo 4 1 0001 1 (1) 2 0011 2 (n+1) 3 0000 3 (0) 4 0100 0 (n) 5 0001 1 (1) 6 0111 2 (n+1) 7 0000 3 (0) 8 1000 0 (n)need an explanation for this answer? contact us directly to get an explanation for this answer