login
Record the number of terms with no proper divisors, then the number with one proper divisor, then two, three, etc., until reaching a zero term. After each zero term, repeat the count as before.
2

%I #20 May 07 2023 09:59:07

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

%T 13,10,6,6,0,14,10,6,10,0,15,10,6,14,0,16,10,6,17,1,1,0,19,12,6,18,1,

%U 3,0,21,13,6,20,1,4,0,23,15,7,21,1,4,0,25,16,9,22,2,4,0,26,17

%N Record the number of terms with no proper divisors, then the number with one proper divisor, then two, three, etc., until reaching a zero term. After each zero term, repeat the count as before.

%C An inventory sequence counting the proper divisors of existing terms, where zero is taken to have no proper divisors (see A032741). After every occurrence of a zero term the incremental count of terms with 0,1,2,... proper divisors is repeated until another zero term is encountered.

%H David A. Corneth, <a href="/A348016/b348016.txt">Table of n, a(n) for n = 0..9999</a>

%e a(0) = 0 because at first there are no terms, therefore there are no terms with no proper divisors.

%e a(1) = 1 because now there is one term (a(0)) which has no proper divisors.

%e a(2) = 0 since there are no terms with one proper divisor.

%e a(3) = 3 since there are now three terms having just one proper divisor (0,1,0).

%e As an irregular triangle the sequence begins:

%e 0, 1, 0;

%e 3, 1, 0;

%e 5, 2, 0;

%e 6, 3, 0;

%e 7, 5, 0;

%e 8, 6, 0;

%e 9, 6, 4, 1, 0;

%e 11, 7, 2, 4, 0;

%e etc.

%o (PARI) first(n) = { t = 0; res = vector(n); l = List([1]); for(i = 2, n, for(i = #l + 1, t+1, listput(l, 0) ); res[i] = l[t + 1]; q = if(l[t + 1] == 0, 0, numdiv(l[t + 1]) - 1); for(i = #l + 1, q + 1, listput(l, 0) ); l[q + 1]++; if(res[i] == 0, t = 0 , t++ ) ); res } \\ _David A. Corneth_, Sep 25 2021

%o (Python)

%o from sympy import divisor_count

%o from collections import Counter

%o def f(n): return 0 if n == 0 else divisor_count(n) - 1

%o def aupton(nn):

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

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

%o c = inventory[num]

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

%o alst.append(c)

%o inventory.update([f(c)])

%o return alst

%o print(aupton(84)) # _Michael S. Branicky_, May 07 2023

%Y Cf. A032741, A342585, A345730, A347791.

%K nonn,tabf

%O 0,4

%A _David James Sycamore_, Sep 24 2021

%E Data corrected and extended by _David A. Corneth_, Sep 25 2021