%I #51 Mar 20 2023 16:33:20
%S 0,1,1,1,3,0,1,2,4,1,1,1,2,7,2,1,1,0,0,1,4,10,3,2,2,0,0,1,0,0,1,8,12,
%T 5,2,2,1,0,1,1,0,1,0,1,11,17,7,2,2,1,0,2,1,0,1,1,1,0,0,0,0,1,17,23,10,
%U 2,2,1,0,2,1,0,2,1,1,0,0,0,0,2,0,0,0,0,0
%N A variant of the inventory sequence A342585: now a row ends when the number of occurrences of the largest term in the sequence thus far has been recorded.
%H Samuel Harkness, <a href="/A361287/b361287.txt">Table of n, a(n) for n = 0..12000</a>
%F a(n) is the number of all a(k) == b(n) 0 <= k < n and b(0) = 0 and b(n) = b(n-1)+1 if an a(k) > b(n) exists for 0 <= k < n, and 0 otherwise.
%e The triangle begins:
%e 0;
%e 1, 1;
%e 1, 3, 0, 1;
%e 2, 4, 1, 1, 1;
%e 2, 7, 2, 1, 1, 0, 0, 1;
%e 4, 10, 3, 2, 2, 0, 0, 1, 0, 0, 1;
%e 8, 12, 5, 2, 2, 1, 0, 1, 1, 0, 1, 0, 1;
%e 11, 17, 7, 2, 2, 1, 0, 2, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1;
%e 17, 23, 10, 2, 2, 1, 0, 2, 1, 0, 2, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1;
%e ...
%e a(0)=0 because we begin each row by recording the number of zeros in the sequence. As yet, there are none. 0 is still the largest term in the sequence, so we begin the next row.
%e a(1)=1 because there is one 0. a(2)=1 because there is one 1. 1 is the largest term thus far, so we begin the next row.
%e a(3)=1 (there is still one zero); a(4)=3 (there are three 1s); a(5)=0 (no 2s); the row ends with a(6)=1 because there is one 3 and three is the largest term thus far.
%t len = 84; K = {0}; While[Length@K <= len, i = 0; While[i <= Max@K, AppendTo[K, Count[K, i]]; i++]]; Print[Take[K, len + 1]] (* _Samuel Harkness_, Mar 12 2023 *)
%o (Python)
%o from collections import Counter
%o from itertools import count, islice
%o def agen(): # generator of terms
%o an, b, m, inventory = 0, 0, 0, Counter([0])
%o for n in count(1):
%o yield an
%o an = inventory[b]
%o m = max(m, an)
%o b = b + 1 if m > b else 0; inventory.update([an])
%o print(list(islice(agen(), 85))) # _Michael S. Branicky_, Mar 07 2023
%Y Cf. A342585, A347317.
%K nonn,tabf
%O 0,5
%A _Robert Dober_, Mar 07 2023
%E More terms from _Alois P. Heinz_, Mar 07 2023
|