OFFSET
1,2
COMMENTS
This sequence written in binary is A139709.
This is a permutation of the positive integers. A139706 is the inverse permutation.
Moreover, the first 2^n terms are a permutation of the first 2^n positive integers. Fixed points of the permutation are A272919. - Ivan Neretin, May 10 2016
REFERENCES
Lionel Levine, Fractal sequences and restricted Nim, Ars Combin. 80 (2006), 113-127.
LINKS
Ivan Neretin, Table of n, a(n) for n = 1..8192
Lionel Levine, Fractal sequences and restricted Nim, arXiv:math/0409408 [math.CO], 2004.
FORMULA
From Mikhail Kurkov, Dec 23 2023: (Start)
a(2^m + k) = f(2^m + f(k)) for m >= 0, 0 <= k < 2^m where f(n) = A059893(n) for n > 0 with f(0) = 0.
a(n) = f(A139706(f(n))). (End)
MAPLE
A139708 := proc(n) local a; a := ListTools[Rotate](convert(n, base, 2), -1) ; while op(-1, a) = 0 do a := ListTools[Rotate](a, -1) ; od: add(op(i, a)*2^(i-1), i=1..nops(a)) : end: seq(A139708(n), n=1..100) ; # R. J. Mathar, May 04 2008
MATHEMATICA
rbd[n_]:=Module[{idn2=RotateLeft[IntegerDigits[n, 2]]}, While[ idn2[[1]] ==0, idn2= RotateLeft[ idn2]]; FromDigits[idn2, 2]]; Array[rbd, 80] (* Harvey P. Dale, Jun 07 2015 *)
Table[FromDigits[RotateLeft[d = IntegerDigits[n, 2], Position[Join[d, d], 1][[2, 1]] - 1], 2], {n, 71}] (* Ivan Neretin, May 10 2016 *)
PROG
(PARI) a(n) = if(bitand(n, n-1)==0, n, my(b=logint(n, 2), s=b-logint(n-(1<<b), 2)); (((n - (1<<b)) << 1) + 1) << (s-1)) \\ Andrew Howroyd, Jan 04 2024
CROSSREFS
KEYWORD
AUTHOR
Leroy Quet, Apr 30 2008
EXTENSIONS
More terms from R. J. Mathar, May 04 2008
STATUS
approved