%I #25 Feb 12 2025 14:57:44
%S 1,3,6,3,10,8,8,1,15,15,21,18,9,3,21,24,39,45,48,30,24,9,3,28,35,62,
%T 82,107,108,101,81,62,37,17,8,1,36,48,90,129,186,222,264,252,255,219,
%U 183,126,90,48,27,9,3,45,63,123,186,285,372,492,561,624,648,651,597,537,435,336,249,165,99,54,27,9,3
%N Triangle read by rows: T(n,k) is the number of ternary words of length n on {0,1,2} that have k inversions (n >= 0, k >= 0).
%C Row n has 1 + floor(n^2/3) terms.
%C Row sums are equal to 3^n = A000244(n).
%C Alternating row sums are 3^(ceiling(n/2)) = A108411(n+1).
%C T(n,0) = (n+1)*(n+2)/2 = A000217(n+1).
%C Sum_{k>=0} k*T(n,k) = 3^(n-1)*n*(n-1)/2 = A129530(n).
%C This sequence is mentioned in the Andrews-Savage-Wilf paper. - _Omar E. Pol_, Jan 30 2012
%D M. Bona, Combinatorics of Permutations, Chapman & Hall/CRC, Boca Raton, FL, 2004, pp. 57-61.
%D G. E. Andrews, The Theory of Partitions, Addison-Wesley, 1976.
%H Alois P. Heinz, <a href="/A129529/b129529.txt">Rows n = 0..50, flattened</a>
%H G. E. Andrews, C. D. Savage and H. S. Wilf, <a href="http://www.math.psu.edu/andrews/pdf/286.pdf">Hypergeometric identities associated with statistics on words</a>
%H Mark A. Shattuck and Carl G. Wagner, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL8/Shattuck2/shattuck44.html">Parity Theorems for Statistics on Lattice Paths and Laguerre Configurations</a>, Journal of Integer Sequences, Vol. 8 (2005), Article 05.5.1.
%F Generating polynomial of row n is Sum_{i=0..n} Sum_{j=0..n-i} binomial[n; i,j,n-i-j], where binomial[n;a,b,c] (a+b+c=n) is a q-multinomial coefficient.
%F Sum_{k=0..floor(n^2/3)} (-1)^k * T(n,k) = A056449(n). - _Alois P. Heinz_, Feb 12 2025
%e T(3,2) = 8 because we have 100, 110, 120, 200, 201, 211, 220 and 221.
%e Triangle starts:
%e 1;
%e 3;
%e 6, 3;
%e 10, 8, 8, 1;
%e 15, 15, 21, 18, 9, 3;
%e 21, 24, 39, 45, 48, 30, 24, 9, 3;
%e ...
%p for n from 0 to 40 do br[n]:=sum(q^i,i=0..n-1) od: for n from 0 to 40 do f[n]:=simplify(product(br[j],j=1..n)) od: mbr:=(n,a,b,c)->simplify(f[n]/f[a]/f[b]/f[c]): for n from 0 to 9 do G[n]:=sort(simplify(sum(sum(mbr(n,a,b,n-a-b),b=0..n-a),a=0..n))) od: for n from 0 to 9 do seq(coeff(G[n],q,j),j=0..floor(n^2/3)) od; # yields sequence in triangular form
%p # second Maple program:
%p b:= proc(n, l) option remember; `if`(n=0, 1, add(expand(b(n-1, `if`(j<3,
%p subsop(j=l[j]+1, l), l)))*x^([0, l[1], l[1]+l[2]][j]), j=1..3))
%p end:
%p T:= n-> (p-> seq(coeff(p, x, i), i=0..degree(p)))(b(n, [0$2])):
%p seq(T(n), n=0..10); # _Alois P. Heinz_, Feb 12 2025
%Y Cf. A000244, A056449, A083906, A108411, A000217, A129530, A129531, A129532.
%K nonn,tabf,changed
%O 0,2
%A _Emeric Deutsch_, Apr 22 2007