A032531 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.
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, 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, 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
Offset: 0
Examples
Triangle begins: 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, 2, 2; 2, 7, 9, 9, 3, 3, 2, 3, 0; ...
Links
- Scott R. Shannon, Table of n, a(n) for n = 0..20000.
- Scott R. Shannon, Image of the first 10^6 terms.
- Scott R. Shannon, Image of the first 10^7 terms.
- Scott R. Shannon, Image of the first 10^8 terms.
- Index entries for sequences related to inventory sequences
Programs
-
Maple
A002262 := proc(n) n - binomial(floor(1/2+sqrt(2*(1+n))), 2); end proc: A032531 := proc(n) option remember; local a,piv,i ; a := 0 ; piv := A002262(n) ; for i from 0 to n-1 do if procname(i) = piv then a := a+1 ; end if; end do: a ; end proc: seq(A032531(n),n=0..100) ; # R. J. Mathar, May 08 2020
-
Mathematica
A002262[n_] := n - Binomial[Floor[1/2 + Sqrt[2*(1 + n)]], 2]; 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]; Table[A032531[n], {n, 0, 100}] (* Jean-François Alcover, Mar 25 2024, after R. J. Mathar *)
-
Python
from math import comb, isqrt from collections import Counter def idx(n): return n - comb((1+isqrt(8+8*n))//2, 2) def aupton(nn): num, alst, inventory = 0, [0], Counter([0]) for n in range(1, nn+1): c = inventory[idx(n)] alst.append(c) inventory[c] += 1 return alst print(aupton(93)) # Michael S. Branicky, May 07 2023
Extensions
New name from Peter Munn, May 06 2023
Comments