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.

A297824 The number of iterations to remove all runs from the binary string 11011100...n (formed by concatenating the first n binary numbers, see A058935(n)).

This page as a plain text file.
%I A297824 #11 Jan 06 2018 22:44:46
%S A297824 0,1,1,1,1,2,2,2,2,4,4,4,4,4,4,4,4,4,4,4,6,4,4,4,4,4,4,4,4,4,4,4,4,4,
%T A297824 4,4,4,4,4,4,4,9,10,10,10,10,10,10,9,8,8,10,7,9,9,9,10,10,10,10,10,10,
%U A297824 10,10,10,10,9,10,9,10,9,10,10,8,9,9,10,10,9,7,9,10,10,10,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
%N A297824 The number of iterations to remove all runs from the binary string 11011100...n (formed by concatenating the first n binary numbers, see A058935(n)).
%C A297824 Each iteration removes all runs of two or more identical bits that appear at the beginning of that iteration. By definition, the bits of the final string will be an initial segment, possibly empty, of 0, 1, 0, 1, ... (A000035) or 1, 0, 1, 0, ... (A059841). A297825 gives the lengths of the final strings; the sign of each nonzero term indicates which case occurs.
%H A297824 Rick L. Shepherd, <a href="/A297824/b297824.txt">Table of n, a(n) for n = 1..10000</a>
%e A297824 a(21) = 6 because 1101110010111011110001001101010111100110111101111100001000110010100111010010101 --> 01001010100011010110101 --> 01101010100101 --> 0010101101 -->  101001 --> 1011 --> 10, where each arrow points to the result of one iteration.
%o A297824 (PARI)
%o A297824 {remove_runs(v) = my(w, run_found = 0);
%o A297824 if(#v == 1, w = v, w = []);
%o A297824 for(k = 2, #v,
%o A297824    if(v[k-1] == v[k],
%o A297824      run_found = 1,
%o A297824      if(run_found == 0, w = concat(w, v[k-1]), run_found = 0);
%o A297824      if(k == #v, w = concat(w, v[k]))
%o A297824    )
%o A297824 ); w}
%o A297824 {a(n) = my(v = [], L,  c = 0); \\ remove "write(...);" if don't need other b-file
%o A297824 for(k = 1, n, v = concat(v, binary(k)));
%o A297824 L = #v;
%o A297824 while(1,
%o A297824   v = remove_runs(v);
%o A297824   if(#v == L, write("b297825.txt", n, " ", L*(if(L == 0, 0, 2*v[1] - 1))); break, L = #v);
%o A297824   c++
%o A297824 ); c}
%o A297824 for(n = 1, 10000, write("b297824.txt", n, " ", a(n))) \\ created two b-files
%Y A297824 Cf. A000035, A059841, A058935, A297825.
%K A297824 nonn,base
%O A297824 1,6
%A A297824 _Rick L. Shepherd_, Jan 06 2018