OFFSET
0,3
COMMENTS
Leading zeros are ignored.
This sequence is a permutation of the nonnegative integers (as it is injective and preserves the binary length); see A333693 for the inverse.
We can devise a variant of this sequence for any fixed base b > 1, by performing a reversal at each nonzero digit in base b.
LINKS
EXAMPLE
For n = 90:
- the binary representation of 90 is "1011010",
- this binary representation evolves as follows (parentheses indicate reversals):
(1)0 1 1 0 1 0
(1 0 1)1 0 1 0
(1 1 0 1)0 1 0
(1 0 1 0 1 1)0
- the resulting binary representation is "1010110"
- and a(90) = 86.
PROG
(PARI) a(n, base=2)={ my (b=digits(n, base), p=[]); for (k=1, #b, p=concat(p, b[k]); if (b[k], p=Vecrev(p))); fromdigits(p, base) }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 04 2020
STATUS
approved