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.

A227738 Irregular table read by rows: each row n (n>=1) lists the positions where the runs of bits change between 0's and 1's in the binary expansion of n, when scanning it from the least significant to the most significant end.

This page as a plain text file.
%I A227738 #37 Aug 13 2025 22:57:07
%S A227738 1,1,2,2,2,3,1,2,3,1,3,3,3,4,1,3,4,1,2,3,4,2,3,4,2,4,1,2,4,1,4,4,4,5,
%T A227738 1,4,5,1,2,4,5,2,4,5,2,3,4,5,1,2,3,4,5,1,3,4,5,3,4,5,3,5,1,3,5,1,2,3,
%U A227738 5,2,3,5,2,5,1,2,5,1,5,5,5,6,1,5,6,1,2,5,6
%N A227738 Irregular table read by rows: each row n (n>=1) lists the positions where the runs of bits change between 0's and 1's in the binary expansion of n, when scanning it from the least significant to the most significant end.
%C A227738 Row n has A005811(n) terms.
%C A227738 As a sequence, seems to have a particular fractal structure, probably allowing additional formulas.
%C A227738 Row n lists the positions of 1-bits in the binary expansion of the Gray code for n, A003188(n), when 1 is the rightmost position. A003188(17) = 25 = 11001_2 gives row 17: 1,4,5. - _Alois P. Heinz_, Feb 01 2023
%H A227738 Antti Karttunen, <a href="/A227738/b227738.txt">The rows 1..1023 of the table, flattened</a>
%H A227738 Wikipedia, <a href="https://en.wikipedia.org/wiki/Gray_code">Gray code</a>
%F A227738 a(n) = A227188(A227737(n),A227740(n)).
%F A227738 Alternatively, if A227740(n) is 0, then a(n) = A227736(n), otherwise a(n) = a(n-1) + A227736(n). [Each row gives cumulative sums of the runlengths of binary representation of n]
%e A227738 Table begins as:
%e A227738   Row  n in    Terms on
%e A227738    n   binary  that row
%e A227738    1      1    1;
%e A227738    2     10    1,2;
%e A227738    3     11    2;
%e A227738    4    100    2,3;
%e A227738    5    101    1,2,3;
%e A227738    6    110    1,3;
%e A227738    7    111    3;
%e A227738    8   1000    3,4;
%e A227738    9   1001    1,3,4;
%e A227738   10   1010    1,2,3,4;
%e A227738   11   1011    2,3,4;
%e A227738   12   1100    2,4;
%e A227738   13   1101    1,2,4;
%e A227738   14   1110    1,4;
%e A227738   15   1111    4;
%e A227738   16  10000    4,5;
%e A227738 etc.
%e A227738 The terms also give the partial sums of runlengths, when the binary expansion of n is scanned from the least significant to the most significant end.
%p A227738 T:= n-> (l-> seq(`if`(l[i]=1, i, [][]), i=1..nops(l)))(
%p A227738                  Bits[Split](Bits[Xor](n, iquo(n, 2)))):
%p A227738 seq(T(n), n=1..50);  # _Alois P. Heinz_, Feb 01 2023
%t A227738 Table[Rest@FoldList[Plus,0,Length/@Split[Reverse[IntegerDigits[n,2]]]],{n,34}]//Flatten (* _Wouter Meeussen_, Aug 31 2013 *)
%o A227738 (Scheme, with _Antti Karttunen_'s IntSeq-library)
%o A227738 (define (A227738 n) (A227188bi (A227737 n) (A227740 n))) ;; The Scheme-function for A227188bi has been given in A227188.
%o A227738 (definec (A227738 n) (if (zero? (A227740 n)) (A227736 n) (+ (A227738 (- n 1)) (A227736 n)))) ;; Alternative definition.
%Y A227738 Each row n (n>=1) contains the initial A005811(n) nonzero terms from the beginning of row n of A227188. A227192(n) gives the sum of terms on row n. A136480 gives the first column.
%Y A227738 Cf. also A227188, A227736, A227739.
%Y A227738 A318926 is a compressed version. If the order is reversed we get A101211 and A318927.
%Y A227738 Cf. A003188, A360287.
%K A227738 nonn,base,tabf
%O A227738 1,3
%A A227738 _Antti Karttunen_, Jul 25 2013