OFFSET
1,2
COMMENTS
EXAMPLE
n=5: x(0)=5, x(1) = 5 xor 6 xor 3 = 0.
n=6: x(0)=6, x(1) = 6 xor 5 xor 3 = 0.
n=9: x(0)=9, x(1) = 9 xor 12 xor 3 = 6, x(2)=0.
n=10: x(0)=10, x(1) = 10 xor 5 xor 5 = 10, and x(i)=10 for i>1.
n=17: x(0)=17, x(1) = 17 xor 24 xor 3 = 10, and x(i)=10 for i>1.
So 5, 6, 9 are in the sequence, 10 and 17 are not.
MATHEMATICA
Select[Range[0, 300], Nest[BitXor[BitXor[#, FromDigits[ RotateRight[ IntegerDigits[#, 2]], 2]], FromDigits[ RotateLeft[ IntegerDigits[#, 2]], 2]] &, #, 120] == 0 &] (* Michael De Vlieger, May 14 2016 *)
PROG
(Python)
def ROR(n): # returns A038572(n)
BL = len(bin(n))-2
return (n>>1) + ((n&1) << (BL-1))
def ROL(n): # returns A006257(n)
BL = len(bin(n))-2
return (n*2) - (1<<BL) + 1
for n in range(1000):
X = n
Xs = []
while not (X in Xs):
Xs.append(X)
if X==0:
print str(n)+', ',
break
X = X ^ ROR(X) ^ ROL(X)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, May 13 2016
STATUS
approved