%I #19 May 15 2021 06:16:45
%S 1,1,2,6,15,44,129,386,1185,3690,11725,37578,122577,402477,1340640,
%T 4490368,15219148,51825464,178235039,615461671,2143127872,7488890027,
%U 26357539204,93050275129,330544091758,1177338456789,4216288462832,15134924595039,54588972553934
%N Number of sets of nonempty words with a total of n letters over quaternary alphabet such that within each prefix of a word every letter of the alphabet is at least as frequent as the subsequent alphabet letter.
%H Alois P. Heinz, <a href="/A293743/b293743.txt">Table of n, a(n) for n = 0..1000</a>
%F G.f.: Product_{j>=1} (1+x^j)^A005817(j).
%p g:= proc(n) option remember; `if`(n<2, 1, (4*(2*n+3)*
%p g(n-1)+16*(n-1)*n*g(n-2))/((n+3)*(n+4)))
%p end:
%p b:= proc(n, i) option remember; `if`(n=0, 1, `if`(i<1, 0,
%p add(b(n-i*j, i-1)*binomial(g(i), j), j=0..n/i)))
%p end:
%p a:= n-> b(n$2):
%p seq(a(n), n=0..35);
%t g[n_] := g[n] = If[n<2, 1, (4(2n+3) g[n-1]+16(n-1) n g[n-2])/((n+3)(n+4))];
%t b[n_, i_] := b[n, i] = If[n==0, 1, If[i<1, 0, Sum[b[n-i j, i-1] Binomial[ g[i], j], {j, 0, n/i}]]];
%t a[n_] := b[n, n];
%t Array[a, 35, 0] (* _Jean-François Alcover_, May 31 2019, from Maple *)
%o (Python)
%o from sympy.core.cache import cacheit
%o from sympy import binomial
%o @cacheit
%o def g(n): return 1 if n<2 else (4*(2*n + 3)*g(n - 1) + 16*(n - 1)*n*g(n - 2))//((n + 3)*(n + 4))
%o @cacheit
%o def b(n, i): return 1 if n==0 else 0 if i<1 else sum([b(n - i*j, i - 1)*binomial(g(i), j) for j in range(n//i + 1)])
%o def a(n): return b(n, n)
%o print([a(n) for n in range(36)]) # _Indranil Ghosh_, Oct 15 2017
%Y Column k=4 of A293112.
%Y Cf. A005817.
%K nonn
%O 0,3
%A _Alois P. Heinz_, Oct 15 2017
|