login
Record the number of distinct terms seen thus far, then the number of distinct terms seen only once, then twice, and so on until recording a zero; whereupon repeat the count.
3

%I #49 Jan 16 2022 13:05:21

%S 0,1,2,0,3,3,2,0,4,2,1,2,1,0,5,2,1,0,6,3,0,7,4,1,1,0,8,4,0,9,5,1,2,0,

%T 10,5,0,11,6,1,3,1,0,12,6,0,13,7,1,3,0,14,7,0,15,8,1,4,1,1,1,0,16,8,0,

%U 17,9,1,4,0,18,9,0,19,10,1,5,1,2,0,20,10,0

%N Record the number of distinct terms seen thus far, then the number of distinct terms seen only once, then twice, and so on until recording a zero; whereupon repeat the count.

%C An Inventory sequence counting the occurrences of distinct terms. After every occurrence of a zero term the count of distinct terms seen so far is recorded, then the count of those seen just once, then twice, etc, until a zero term occurs again, whereupon the count is reset. The first reset occurs after a(0), the first zero term. (see A342585, A348016).

%H Michael S. Branicky, <a href="/A347564/b347564.txt">Table of n, a(n) for n = 0..24999</a>

%e a(0) must be 0 because at this point no distinct terms have been seen.

%e Following zero term a(0), we start again, a(1) = 1 since there is only one distinct term in the sequence so far; namely a(0) = 0.

%e a(2) = 2 because now there are two distinct terms (0,1) each of which have appeared just once.

%e a(3) = 0 since there are no distinct terms which have appeared twice.

%e Following zero term a(3) we start again; a(4) = 3, since there are now 3 distinct terms (0,1,2) in the sequence so far.

%e a(5) = 3 because only three distinct terms (1,2,3) have appeared just once.

%e a(6) = 2 since there are two terms (0, 3) which have occurred twice.

%e As an irregular table the sequence starts:

%e 0;

%e 1, 2, 0;

%e 3, 3, 2, 0;

%e 4, 2, 1, 2, 1, 0;

%e 5, 2, 1, 0;

%e 6, 3, 0;

%e 7, 4, 1, 1, 0;

%o (Python)

%o from collections import Counter

%o def aupton(terms):

%o num, alst, inventory = 0, [0], Counter([0])

%o for n in range(2, terms+1):

%o if num == 0:

%o c = len(inventory)

%o else:

%o c = sum(inventory[i] == num for i in inventory)

%o num = 0 if c == 0 else num + 1

%o alst.append(c)

%o inventory.update([c])

%o return alst

%o print(aupton(83)) # _Michael S. Branicky_, Oct 06 2021

%Y Cf. A342585, A348016.

%K nonn,tabf

%O 0,3

%A _David James Sycamore_, Sep 29 2021

%E a(45) and beyond from _Michael S. Branicky_, Oct 06 2021