%I #9 Aug 28 2021 03:24:57
%S 5,15,119,421,2254,8999,40349,166817,737829,3008774,13186593,54944783,
%T 238422808,1010671048,4395831546,18821162274,82799233661,359711480525,
%U 1599420076729,7030074945271,31626819884986,141486845119777,646988113794544,2940338763342920
%N Number of standard Young tableaux with n cells such that the lengths of the first and the last row differ by 4.
%C Also the number of ballot sequences of length n such that the multiplicities of the largest and the smallest value differ by 4.
%H Alois P. Heinz, <a href="/A244298/b244298.txt">Table of n, a(n) for n = 6..100</a>
%p h:= proc(l) local n; n:=nops(l); add(i, i=l)!/mul(mul(1+l[i]-j+
%p add(`if`(l[k]>=j, 1, 0), k=i+1..n), j=1..l[i]), i=1..n) end:
%p g:= proc(n, i, l) local j; `if`(n=0 or i<1, 0, `if`(l<>[] and
%p l[1]-i=4, `if`(irem(n, i, 'j')=0, h([l[], i$j]), 0),
%p add(g(n-i*j, i-1, [l[], i$j]), j=0..n/i)))
%p end:
%p a:= n-> g(n$2, []):
%p seq(a(n), n=6..35);
%t h[l_] := With[{n = Length[l]}, Total[l]!/Product[Product[1 + l[[i]] - j + Sum[If[l[[k]] >= j, 1, 0], {k, i + 1, n}], {j, l[[i]]}], {i, n}]];
%t g[n_, i_, l_] := Module[{j}, If[n == 0 || i < 1, 0, If[l != {} && l[[1]] - i == 4, If[j = Quotient[n, i]; Mod[n, i] == 0, h[Join[l, Table[i, {j}]]], 0], Sum[g[n - i*j, i - 1, Join[l, Table[i, {j}]]], {j, 0, n/i}]]]];
%t a[n_] := g[n, n, {}];
%t Table[a[n], {n, 6, 35}] (* _Jean-François Alcover_, Aug 28 2021, after Maple code *)
%Y Column k=4 of A238707.
%K nonn
%O 6,1
%A _Joerg Arndt_ and _Alois P. Heinz_, Jun 25 2014