OFFSET
0,3
COMMENTS
LINKS
FORMULA
MATHEMATICA
Join[{0, 1}, Table[d = IntegerDigits[n, 2]; FromDigits[Join[{d[[1]]}, BitXor[Most@Rest@d, Rest@Rest@d], {d[[-1]]}], 2], {n, 2, 68}]] (* Ivan Neretin, Dec 28 2016 *)
PROG
(Python)
for n in range(99):
bits = [0]*64
orig = [0]*64
l = int.bit_length(int(n))
t = n
for i in range(l):
bits[i] = orig[i] = t&1
t>>=1
for i in range(1, l-1): bits[i] ^= orig[i-1] # A231550
#for i in range(1, l-1): bits[i] ^= bits[i-1] # A231551
#for i in range(l-1): bits[i] ^= orig[i+1] # A003188
#for i in range(1, l): bits[l-1-i] ^= bits[l-i] # A006068
t = 0
for i in range(l): t += bits[i]<<i
print(str(t), end=', ')
(R)
a <- 1
maxlevel <- 8 # by choice
#
for(m in 0:maxlevel) for(k in 0:(2^m-1)){
a[2^(m+1) +2*k] <- 2*a[2^m+k]
a[2^(m+2)-1-2*k] <- 2*a[2^m+k] + 1
}
(a <- c(0, a))
# Yosu Yurramendi, Apr 10 2017
(PARI) a(n) = bitxor(n, if(n>3, bitand(n<<1, bitneg(0, logint(n, 2))))); \\ Kevin Ryde, Jul 17 2021
CROSSREFS
KEYWORD
AUTHOR
Alex Ratushnyak, Nov 10 2013
STATUS
approved