OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative integers (as it is injective and preserves the binary length); see A333777 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 0 1(0 1 0 1)
1(1 0 1 0 1 0)
- the resulting binary representation is "1101010"
- and a(90) = 106.
The binary plot of the first terms is as follows (#'s denote 1's):
################################
################ # # ## #### ########
######## # # ## #### ## # # ## # # #### # # ##
#### # # ## ## # # ## # # #### # # ## ## # # ## # #
## # # ## # # #### # # ## ######## # # ## ####
# # ## #### ######## ################
1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890123
PROG
(PARI) a(n, base=2) = { my (d=digits(n, base), t=[]); forstep (k=#d, 1, -1, if (d[k], t=Vecrev(t)); t=concat(d[k], t)); fromdigits(t, base); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 05 2020
STATUS
approved