login
An inventory sequence: triangle read by rows, where T(n, k), 0 <= k <= n, records the number of k's thus far in the flattened sequence.
8

%I #47 Mar 25 2024 08:13:51

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

%T 2,2,2,7,9,9,3,3,2,3,0,3,7,10,13,3,3,2,4,0,2,4,7,12,15,5,4,2,5,0,2,1,

%U 5,8,14,15,6,6,4,5,1,2,1,0,6,10,15,15,7,7,5,7,1,2,2,0,1,7,12,17

%N An inventory sequence: triangle read by rows, where T(n, k), 0 <= k <= n, records the number of k's thus far in the flattened sequence.

%C Old name: a(n) = number of a(i) for 0<=i<n that are equal to A002262(n).

%C This sequence is a variation of the Inventory sequence A342585. The same rules apply except that in this variation each row ends after k terms, where k is the current row count which starts at 1. The behavior up to the first 1 million terms is similar to A342585 but beyond that the most common terms do not increase, likely due to the rows being cut off after k terms thus numbers such as 1 and 2 no longer make regular appearances. Larger number terms do increase and overtake the leading early terms, and it appears this pattern repeats as n increases. See the linked images. - _Scott R. Shannon_, Sep 13 2021

%C The complexity of this sequence derives from the totals being updated during the calculation of each row. If each row recorded an inventory of only the earlier rows, we would get the much simpler A025581. - _Peter Munn_, May 06 2023

%H Scott R. Shannon, <a href="/A032531/b032531.txt">Table of n, a(n) for n = 0..20000</a>.

%H Scott R. Shannon, <a href="/A032531/a032531.png">Image of the first 10^6 terms</a>.

%H Scott R. Shannon, <a href="/A032531/a032531_1.gif">Image of the first 10^7 terms</a>.

%H Scott R. Shannon, <a href="/A032531/a032531.gif">Image of the first 10^8 terms</a>.

%H <a href="/index/In#inventory">Index entries for sequences related to inventory sequences</a>

%p A002262 := proc(n)

%p n - binomial(floor(1/2+sqrt(2*(1+n))), 2);

%p end proc:

%p A032531 := proc(n)

%p option remember;

%p local a,piv,i ;

%p a := 0 ;

%p piv := A002262(n) ;

%p for i from 0 to n-1 do

%p if procname(i) = piv then

%p a := a+1 ;

%p end if;

%p end do:

%p a ;

%p end proc:

%p seq(A032531(n),n=0..100) ; # _R. J. Mathar_, May 08 2020

%t A002262[n_] := n - Binomial[Floor[1/2 + Sqrt[2*(1 + n)]], 2];

%t A032531[n_] := A032531[n] = Module[{a, piv, i}, a = 0; piv = A002262[n]; For[i = 0, i <= n-1, i++, If[A032531[i] == piv, a++]]; a];

%t Table[A032531[n], {n, 0, 100}] (* _Jean-François Alcover_, Mar 25 2024, after _R. J. Mathar_ *)

%o (Python)

%o from math import comb, isqrt

%o from collections import Counter

%o def idx(n): return n - comb((1+isqrt(8+8*n))//2, 2)

%o def aupton(nn):

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

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

%o c = inventory[idx(n)]

%o alst.append(c)

%o inventory[c] += 1

%o return alst

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

%Y Cf. A002262, A025581, A342585.

%K nonn,tabl,look

%O 0,5

%A Dmitri Papichev (Dmitri.Papichev(AT)iname.com)

%E New name from _Peter Munn_, May 06 2023