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.

A245562 Table read by rows: row n gives list of lengths of runs of 1's in binary expansion of n, starting with high-order bits.

This page as a plain text file.
%I A245562 #23 May 22 2025 10:21:39
%S A245562 0,1,1,2,1,1,1,2,3,1,1,1,1,1,1,2,2,2,1,3,4,1,1,1,1,1,1,2,1,1,1,1,1,1,
%T A245562 2,1,3,2,2,1,2,1,2,2,3,3,1,4,5,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,3,1,1,1,
%U A245562 1,1,1,1,1,1,1,2,1,2,1,2,1,1,3,1,4,2,2,1
%N A245562 Table read by rows: row n gives list of lengths of runs of 1's in binary expansion of n, starting with high-order bits.
%C A245562 A formula for A071053(n) depends on this table.
%H A245562 Reinhard Zumkeller, <a href="/A245562/b245562.txt">Table of n, a(n) for n = 0..2770</a>
%H A245562 N. J. A. Sloane, <a href="http://arxiv.org/abs/1503.01168">On the Number of ON Cells in Cellular Automata</a>, arXiv:1503.01168, 2015
%e A245562 Here are the run lengths for the numbers 0 through 21:
%e A245562 0, []
%e A245562 1, [1]
%e A245562 2, [1]
%e A245562 3, [2]
%e A245562 4, [1]
%e A245562 5, [1, 1]
%e A245562 6, [2]
%e A245562 7, [3]
%e A245562 8, [1]
%e A245562 9, [1, 1]
%e A245562 10, [1, 1]
%e A245562 11, [1, 2]
%e A245562 12, [2]
%e A245562 13, [2, 1]
%e A245562 14, [3]
%e A245562 15, [4]
%e A245562 16, [1]
%e A245562 17, [1, 1]
%e A245562 18, [1, 1]
%e A245562 19, [1, 2]
%e A245562 20, [1, 1]
%e A245562 21, [1, 1, 1]
%p A245562 for n from 0 to 128 do
%p A245562 lis:=[]; t1:=convert(n,base,2); L1:=nops(t1); out1:=1; c:=0;
%p A245562 for i from 1 to L1 do
%p A245562    if out1 = 1 and t1[i] = 1 then out1:=0; c:=c+1;
%p A245562    elif out1 = 0 and t1[i] = 1 then c:=c+1;
%p A245562    elif out1 = 1 and t1[i] = 0 then c:=c;
%p A245562    elif out1 = 0 and t1[i] = 0 then lis:=[c,op(lis)]; out1:=1; c:=0;
%p A245562    fi;
%p A245562    if i = L1 and c>0 then lis:=[c,op(lis)]; fi;
%p A245562                    od:
%p A245562 lprint(n,lis);
%p A245562 od:
%o A245562 (Python)
%o A245562 from re import split
%o A245562 A245562_list = [0]
%o A245562 for n in range(1,100):
%o A245562     A245562_list.extend(len(d) for d in split('0+',bin(n)[2:]) if d != '')
%o A245562 # _Chai Wah Wu_, Sep 07 2014
%o A245562 (PARI) row(n)=my(v=List(),k); while(n, n>>=valuation(n,2); listput(v, k=valuation(n+1,2)); n>>=k); Vecrev(v) \\ _Charles R Greathouse IV_, Oct 21 2016
%Y A245562 Row sums = A000120 (the binary weight).
%Y A245562 Cf. A245563, A071053.
%K A245562 nonn,base,tabf,easy
%O A245562 0,4
%A A245562 _N. J. A. Sloane_, Aug 10 2014