OFFSET
0,3
COMMENTS
This permutation is induced by the third Lamplighter group generating wreath recursion a = s(b,a), b = (a,b) (i.e., binary transducer, where s means that the bits at that state are toggled: 0 <-> 1) given on page 104 of Bondarenko, Grigorchuk, et al. paper, starting from the active (swapping) state a and rewriting bits from the second most significant bit to the least significant end.
LINKS
A. Karttunen, Table of n, a(n) for n = 0..2047
I. Bondarenko, R. Grigorchuk, R. Kravchenko, Y. Muntyan, V. Nekrashevych, D. Savchuk, Z. Sunic, Classification of groups generated by 3-state automata over a 2-letter alphabet, pp. 8--9 & 103, arXiv:0803.3555 [math.GR], 2008.
R. I. Grigorchuk and A. Zuk, The lamplighter group as a group generated by a 2-state automaton and its spectrum, Geometriae Dedicata, vol. 87 (2001), no. 1-3, pp. 209-244.
S. Wolfram, R. Lamy, Discussion on the NKS Forum
EXAMPLE
475 = 111011011 in binary. Starting from the second most significant bit and, as we begin with the swapping state a, we complement the bits up to and including the first zero encountered and so the beginning of the binary expansion is complemented as 1001....., then, as we switch to the inactive state b, the following bits are kept same, again up to and including the first zero encountered, after which the binary expansion is 1001110.., after which we switch again to the active state (state a), which complements the two rightmost 1's and we obtain the final answer 100111000, which is 312's binary representation, thus a(475)=312.
PROG
(MIT Scheme:) (define (A154435 n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (state 1) (z 1)) (if (zero? maskbit) z (let ((dombit (modulo (floor->exact (/ n maskbit)) 2))) (cond ((= 0 dombit) (loop (floor->exact (/ maskbit 2)) (- 1 state) (+ z z (modulo (- state dombit) 2)))) (else (loop (floor->exact (/ maskbit 2)) state (+ z z (modulo (- state dombit) 2))))))))))
(Python)
from sympy import floor
def a006068(n):
s=1
while True:
ns=n>>s
if ns==0: break
n=n^ns
s<<=1
return n
def a054429(n): return 1 if n==1 else 2*a054429(floor(n/2)) + 1 - n%2
def a(n): return 0 if n==0 else a054429(a006068(a054429(n))) # Indranil Ghosh, Jun 11 2017
(R)
maxn <- 63 # by choice
a <- c(1, 3, 2) # If it were a <- 1:3, it would be A180200
for(n in 2:maxn){
a[2*n ] <- 2*a[n] + (a[n]%%2 == 0)
a[2*n+1] <- 2*a[n] + (a[n]%%2 != 0) }
a
# Yosu Yurramendi, Jun 21 2020
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Jan 17 2009
EXTENSIONS
Spelling/notation corrections by Charles R Greathouse IV, Mar 18 2010
STATUS
approved