login
The Kruskal-Macaulay function M_2(n).
13

%I #34 Oct 17 2022 10:45:06

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

%T 8,8,8,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,

%U 11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13

%N The Kruskal-Macaulay function M_2(n).

%C Identical to A002024, except for the initial 0.

%C Write n (uniquely) as n = C(n_t,t) + C(n_{t-1},t-1) + ... + C(n_v,v) where n_t > n_{t-1} > ... > n_v >= v >= 1. Then M_t(n) = C(n_t-1,t-1) + C(n_{t-1}-1,t-2) + ... + C(n_v-1,v-1).

%D D. E. Knuth, The Art of Computer Programming, Vol. 4, Fascicle 3, Section 7.2.1.3, Table 3.

%H Vincenzo Librandi, <a href="/A123578/b123578.txt">Table of n, a(n) for n = 0..1000</a>

%H B. M. Abrego, S. Fernandez-Merchant, B. Llano, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL14/Abrego/abrego2.html">An Inequality for Macaulay Functions</a>, J. Int. Seq. 14 (2011) # 11.7.4

%p lowpol := proc(n,t) local x::integer ; x := floor( (n*factorial(t))^(1/t)) ; while binomial(x,t) <= n do x := x+1 ; od ; RETURN(x-1) ; end:

%p C := proc(n,t) local nresid,tresid,m,a ; nresid := n ; tresid := t ; a := [] ; while nresid > 0 do m := lowpol(nresid,tresid) ; a := [op(a),m] ; nresid := nresid - binomial(m,tresid) ; tresid := tresid-1 ; od ; RETURN(a) ; end:

%p M := proc(n,t) local a ; a := C(n,t) ; add( binomial(op(i,a)-1,t-i),i=1..nops(a)) ; end:

%p A123578 := proc(n) M(n,2) ; end: # _R. J. Mathar_, Mar 14 2007

%p a := proc(n) local t, s; t := 1; s := 0;

%p while t <= n do s := s + 1; t := t + s od; s end:

%p seq(a(n), n=0..84); # _Peter Luschny_, Oct 18 2017

%t lowpol[n_, t_] := Module[{x = Floor[(n*t!)^(1/t)]}, While[Binomial[x, t] <= n, x = x+1]; x-1]; c[n_, t_] := Module[{nresid = n, tresid = t, a = {}, m}, While[nresid > 0, m = lowpol[nresid, tresid]; AppendTo[a, m]; nresid = nresid - Binomial[m, tresid]; tresid = tresid-1]; a]; m[n_, t_] := With[{a = c[n, t]}, Sum[ Binomial[ a[[i]]-1, t-i], {i, 1, Length[a]}]]; a[n_] := m[n, 2]; Table[a[n], {n, 0, 84}] (* _Jean-François Alcover_, Dec 04 2012, translated from _R. J. Mathar_'s Maple program *)

%o (PARI) A123578(n)=(sqrtint(8*n)+1)\2 \\ _M. F. Hasler_, Apr 19 2014

%o (Python)

%o from math import isqrt

%o def A123578(n): return isqrt(n<<3)+1>>1 # _Chai Wah Wu_, Oct 17 2022

%Y For M_i(n), i=1, 2, 3, 4, 5 see A000127, A123578, A123579, A123580, A123731.

%K nonn,easy

%O 0,3

%A _N. J. A. Sloane_, Nov 12 2006