OFFSET
0,3
COMMENTS
This permutation of natural numbers is induced by the second generator of group 2861 mentioned on page 144 of "Classification of groups generated by 3-state automata over a 2-letter alphabet" paper. It can be computed by starting scanning n's binary expansion rightward from the second most significant bit, complementing every bit down to and including A) either the first 0-bit at odd distance from the most significant bit or B) the first 1-bit at even distance from the most significant bit.
LINKS
A. Karttunen, Table of n, a(n) for n = 0..2047
Bondarenko, Grigorchuk, Kravchenko, Muntyan, Nekrashevych, Savchuk, Sunic, Classification of groups generated by 3-state automata over a 2-letter alphabet, arXiv:0803.3555 [math.GR], 2008, p. 144.
EXAMPLE
25 = 11001 in binary, the first zero-bit at odd distance from the msb is at position 1 (distance 3) and the first one-bit at even distance from the msb is at position 0 (distance 4), thus we stop at the former, after complementing the bits 3-1, which gives us 10111 (23 in binary), thus a(25)=23.
PROG
(MIT Scheme:) (define (A154447 n) (if (< n 2) n (let loop ((maskbit (A072376 n)) (p 0) (z n)) (cond ((zero? maskbit) z) ((= p (modulo (floor->exact (/ n maskbit)) 2)) (+ z (* (- 1 (* 2 p)) maskbit))) (else (loop (floor->exact (/ maskbit 2)) (- 1 p) (- z (* (- 1 (* 2 p)) maskbit))))))))
(R)
maxlevel <- 5 # by choice
a <- 1
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+1) + 2*k + 1] <- 2*a[2^m + k] + 1
}
x <- floor(2^m*5/3)
a[2*x ] <- 2*a[x] + 1
a[2*x + 1] <- 2*a[x]
}
(a <- c(0, a))
# Yosu Yurramendi, Oct 12 2020
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Jan 17 2009
STATUS
approved