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.

A341406 Run lengths of the bits in A308092, read in binary.

This page as a plain text file.
%I A341406 #30 Aug 12 2022 19:14:01
%S A341406 2,1,8,1,3,2,3,3,3,4,3,5,3,6,3,7,2,1,10,1,11,1,9,1,2,1,9,2,2,1,8,1,5,
%T A341406 1,8,1,3,1,2,1,8,1,3,1,3,1,8,1,3,1,1,1,2,1,8,1,3,1,1,2,2,1,8,1,3,2,5,
%U A341406 1,8,1,3,2,3,1,2,1,8,1,3,2,3,2,2,1,8,1
%N A341406 Run lengths of the bits in A308092, read in binary.
%H A341406 Peter Kagey, <a href="https://math.stackexchange.com/q/4081203/121988">Run lengths of bits and run lengths of an auxiliary sequence</a>, Mathematics Stack Exchange.
%e A341406 In binary, A308092 is 1, 10, 11, 111, 1110, 11100, 111000, 1110000, .... The sequence begins with a(1) = 2 ones followed by a(2) = 1 zeros, a(3) = 8 ones, a(4) = 1 zeros, a(5) = 3 ones, a(6) = 2 zeros, and so on.
%e A341406 This sequence first disagrees with A342937 at n = 51, where a(51) = 1 and
%e A341406 A342937(51) = 2.
%o A341406 (Python)
%o A341406 from itertools import groupby
%o A341406 def aupton(terms):
%o A341406   A308092, bstr, rl_lst, rl_idx, n = [1, 2], "110", [2], 2, 3
%o A341406   while len(rl_lst) < terms:
%o A341406     an = int(bstr[:n], 2) - int(bstr[:n-1], 2)
%o A341406     A308092, bstr, n = A308092 + [an], bstr + bin(an)[2:], n+1
%o A341406     new_runs = [len(list(g)) for k, g in groupby(bstr[rl_idx:])]
%o A341406     if len(new_runs) > 1:
%o A341406       rl_idx += sum(new_runs[:-1])
%o A341406       rl_lst.extend(new_runs[:-1]) # don't take last one in case mid-run
%o A341406   return rl_lst[:terms]
%o A341406 print(aupton(86)) # _Michael S. Branicky_, Apr 03 2021
%Y A341406 Cf. A308092, A342937.
%K A341406 nonn,base
%O A341406 1,1
%A A341406 _Peter Kagey_, Mar 31 2021