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.

A347317 An alternative version of the inventory sequence A342585: now a row only ends when a 0 is reached that would not be followed by any further terms.

This page as a plain text file.
%I A347317 #31 Oct 13 2021 10:26:39
%S A347317 0,1,1,0,2,2,2,0,3,2,4,1,1,0,4,4,4,1,4,0,5,5,4,1,6,2,1,0,6,7,5,1,6,3,
%T A347317 3,1,0,7,9,5,3,6,4,4,2,0,1,0,9,10,6,4,9,4,5,2,0,3,1,0,11,11,7,5,10,6,
%U A347317 6,3,0,3,2,2,0
%N A347317 An alternative version of the inventory sequence A342585: now a row only ends when a 0 is reached that would not be followed by any further terms.
%C A347317 This sequence has offset 0, which seems more appropriate than the offset 1 that A342585 has.
%C A347317 In both A342585 and the present sequence, a row records the numbers of 0's, 1's, 2's, etc., in the sequence so far.
%C A347317 The difference is that in A342585 a row ends when the first 0 is reached. The row beginning 7, for example, is 7,  9,  5,  3,  6,  4,  4,  2,  0, and ends, because there is no 8 in the sequence up to this point. However, there is a 9, so we can say that the row ended prematurely.
%C A347317 In the present sequence we continue the row until we reach a 0 which is 1 more than the highest term in the sequence up to that point, and then the row ends.
%C A347317 So the row beginning 7 is now 7,  9,  5,  3,  6,  4,  4,  2,  0,  1,  0.
%C A347317 From this point on the two sequences differ.
%C A347317 Unfortunately, this version has the drawback that most of the entries are zero!
%H A347317 Michael S. Branicky, <a href="/A347317/b347317.txt">Table of n, a(n) for n = 0..25000</a>
%e A347317 The triangle begins:
%e A347317    0;
%e A347317    1,  1,  0;
%e A347317    2,  2,  2,  0;
%e A347317    3,  2,  4,  1,  1,  0;
%e A347317    4,  4,  4,  1,  4,  0;
%e A347317    5,  5,  4,  1,  6,  2,  1,  0;
%e A347317    6,  7,  5,  1,  6,  3,  3,  1,  0;
%e A347317    7,  9,  5,  3,  6,  4,  4,  2,  0,  1,  0;
%e A347317    9, 10,  6,  4,  9,  4,  5,  2,  0,  3,  1,  0;
%e A347317   11, 11,  7,  5, 10,  6,  6,  3,  0,  3,  2,  2,  0;
%e A347317 ...
%t A347317 Block[{c, k, m, r = 0}, c[0] = 1; {0}~Join~Reap[Do[k = 0; While[k <= r, If[IntegerQ@ c[k], Set[m, c[k]], Set[c[k], 0]; Set[m, 0]]; If[m > r, r = m]; Sow[m]; If[IntegerQ@ c[m], c[m]++, c[m] = 1]; k++]; Sow[0]; c[0]++, 9]][[-1, -1]]] (* _Michael De Vlieger_, Oct 12 2021 *)
%o A347317 (Python)
%o A347317 from collections import Counter
%o A347317 def aupton(terms):
%o A347317     num, alst, inventory = 0, [0], Counter([0])
%o A347317     for n in range(2, terms+1):
%o A347317         c = inventory[num]
%o A347317         if c == 0 and num > max(inventory):
%o A347317             num = 0
%o A347317         else:
%o A347317             num += 1
%o A347317         alst.append(c); inventory.update([c])
%o A347317     return alst
%o A347317 print(aupton(73)) # _Michael S. Branicky_, Sep 09 2021
%Y A347317 Cf. A342585. See A347318 for row lengths.
%K A347317 nonn,tabf
%O A347317 0,5
%A A347317 _N. J. A. Sloane_, Sep 09 2021