cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A333776 Scan the binary representation of n from right to left; at each 1, reverse the bits to the right and excluding this 1. The resulting binary representation is that of a(n).

This page as a plain text file.
%I A333776 #10 Apr 07 2020 12:19:52
%S A333776 0,1,2,3,4,6,5,7,8,12,10,14,9,11,13,15,16,24,20,28,18,22,26,30,17,19,
%T A333776 21,23,25,29,27,31,32,48,40,56,36,44,52,60,34,38,42,46,50,58,54,62,33,
%U A333776 35,37,39,41,45,43,47,49,57,53,61,51,55,59,63,64,96,80
%N A333776 Scan the binary representation of n from right to left; at each 1, reverse the bits to the right and excluding this 1. The resulting binary representation is that of a(n).
%C A333776 This sequence is a permutation of the nonnegative integers (as it is injective and preserves the binary length); see A333777 for the inverse.
%C A333776 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.
%H A333776 Rémy Sigrist, <a href="/A333776/b333776.txt">Table of n, a(n) for n = 0..8192</a>
%H A333776 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%H A333776 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A333776 a(2*n) <= 2*a(n) with equality iff n = 0 or n is a power of 2.
%F A333776 A000120(a(n)) = A000120(n).
%e A333776 For n = 90:
%e A333776 - the binary representation of 90 is "1011010",
%e A333776 - this binary representation evolves as follows (parentheses indicate reversals):
%e A333776     1 0 1 1 0 1(0)
%e A333776     1 0 1 1(0 1 0)
%e A333776     1 0 1(0 1 0 1)
%e A333776     1(1 0 1 0 1 0)
%e A333776 - the resulting binary representation is "1101010"
%e A333776 - and a(90) = 106.
%e A333776 The binary plot of the first terms is as follows (#'s denote 1's):
%e A333776                                   ################################
%e A333776                   ################ # #  ##    ####        ########
%e A333776           ######## # #  ##    ####  ## # #  ## # #    #### # #  ##
%e A333776       #### # #  ##  ## # #  ## # #    #### # #  ##  ## # #  ## # #
%e A333776     ## # #  ## # #    #### # #  ##        ######## # #  ##    ####
%e A333776    # #  ##    ####        ########                ################
%e A333776             1         2         3         4         5         6
%e A333776   0123456789012345678901234567890123456789012345678901234567890123
%o A333776 (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); }
%Y A333776 See A333692 for a similar sequence.
%Y A333776 Cf. A000120, A330081, A333777 (inverse), A333778 (fixed points).
%K A333776 nonn,base
%O A333776 0,3
%A A333776 _Rémy Sigrist_, Apr 05 2020