login
Triangle read by rows: T(n,k) is the number of permutations of {1,2,...,n} with k parity changes (n>=2; 1<=k <=n-1); the permutation 372185946 has 5 parity changes: 37-2-1-8-59-46.
4

%I #22 Jan 09 2024 16:30:16

%S 2,4,2,8,8,8,24,36,48,12,72,144,288,144,72,288,720,1728,1296,864,144,

%T 1152,3456,10368,10368,10368,3456,1152,5760,20160,69120,86400,103680,

%U 51840,23040,2880,28800,115200,460800,691200,1036800,691200,460800,115200,28800

%N Triangle read by rows: T(n,k) is the number of permutations of {1,2,...,n} with k parity changes (n>=2; 1<=k <=n-1); the permutation 372185946 has 5 parity changes: 37-2-1-8-59-46.

%C Sum of entries in row n is n! (A000142(n)).

%C T(n,n-1) = A092186(n).

%C T(n,1) = A152875(n).

%C Sum_{k=1..n-1} k*T(n,k) = 2*A077613(n).

%H Alois P. Heinz, <a href="/A152874/b152874.txt">Rows n = 2..150, flattened</a>

%F T(2n,k) = (n!)^2*a(n,k), where a(n,k) is the number of lattice paths from (0,0) to (n,n) with steps N=(0,1) and E=(1,0) and having k turns;

%F a(n,k) = 2*binomial(n-1,k/2-1)*binomial(n-1,k/2) if k even;

%F a(n,k) = 2*(binomial(n-1,(k-1)/2))^2 if k odd.

%F T(2n+1,k) = n!*(n+1)!*b(n,k), where b(n,k) is the number of lattice paths from (0,0) to (n,n+1) with steps N=(0,1) and E=(1,0) and having k turns;

%F b(n,k) = binomial(n,k/2)*binomial(n-1,k/2-1) + binomial(n,k/2-1)*binomial(n-1,k/2) = (binomial(n,k/2))^2*k(2n-k+1)/(n(2n-k+2)) if k even;

%F b(n,k) = 2*binomial(n,(k-1)/2)*binomial(n-1,(k-1)/2) if k odd.

%e T(4,3) = 8 because we have 1243, 1423, 4132, 4312, 2134, 2314, 3241 and 3421.

%e Triangle starts:

%e 2;

%e 4, 2;

%e 8, 8, 8;

%e 24, 36, 48, 12;

%e 72, 144, 288, 144, 72;

%e ...

%p ae := proc (n, k) if `mod`(k, 2) = 0 then 2*factorial(n)^2*binomial(n-1, (1/2)*k-1)*binomial(n-1, (1/2)*k) else 2*factorial(n)^2*binomial(n-1, (1/2)*k-1/2)^2 end if end proc: ao := proc (n, k) if `mod`(k, 2) = 0 then factorial(n)*factorial(n+1)*(binomial(n, (1/2)*k)*binomial(n-1, (1/2)*k-1)+binomial(n, (1/2)*k-1)*binomial(n-1, (1/2)*k)) else 2*factorial(n)*factorial(n+1)*binomial(n, (1/2)*k-1/2)*binomial(n-1, (1/2)*k-1/2) end if end proc: T := proc (n, k) if `mod`(n, 2) = 0 then ae((1/2)*n, k) else ao((1/2)*n-1/2, k) end if end proc: for n from 2 to 10 do seq(T(n, k), k = 1 .. n-1) end do; # yields sequence in triangular form

%p # second Maple program:

%p b:= proc(x, y, t) option remember; `if`(x+y=0, 1, `if`(x>0,

%p b(x-1, y, z)*x, 0)+`if`(y>0, expand(b(y-1, x, z)*y*t), 0))

%p end:

%p T:= n-> (h-> (p-> seq(coeff(p, z, i), i=1..n-1))(b(h, n-h, 1)))(iquo(n, 2)):

%p seq(T(n), n=2..12); # _Alois P. Heinz_, May 23 2023

%t b[x_, y_, t_] := b[x, y, t] = If[x + y == 0, 1, If[x > 0, b[x - 1, y, z]*x, 0] + If[y > 0, Expand[b[y - 1, x, z]*y*t], 0]];

%t T[n_] := Table[Coefficient[#, z, i], {i, 1, n-1}]&[b[#, n-#, 1]]&[ Quotient[n, 2]];

%t Table[T[n], {n, 2, 12}] // Flatten (* _Jean-François Alcover_, Aug 16 2023, after _Alois P. Heinz_ *)

%Y Cf. A000142, A077613, A092186.

%Y T(2n,n) gives A363180.

%K nonn,tabl

%O 2,1

%A _Emeric Deutsch_, Dec 15 2008