cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A152660 Triangle read by rows: T(n,k) is the number of permutations of [n] for which k is the maximal number of initial entries whose parities alternate (1 <= k <= n).

Original entry on oeis.org

1, 0, 2, 2, 2, 2, 8, 8, 0, 8, 48, 36, 12, 12, 12, 288, 216, 72, 72, 0, 72, 2160, 1440, 576, 432, 144, 144, 144, 17280, 11520, 4608, 3456, 1152, 1152, 0, 1152, 161280, 100800, 43200, 28800, 11520, 8640, 2880, 2880, 2880, 1612800, 1008000, 432000, 288000, 115200, 86400, 28800, 28800, 0, 28800
Offset: 1

Views

Author

Emeric Deutsch, Dec 12 2008

Keywords

Comments

Sum of entries in row n is n! (=A000142(n)).
T(n,n) = A092186(n) (the parity alternating permutations; see the Tanimoto reference).
T(n,1) = A152661(n).

Examples

			T(4,2)=8 because we have 1243, 1423, 2134, 2314, 3241, 3421, 4132 and 4312.
Triangle starts:
    1;
    0,   2;
    2,   2,   2;
    8,   8,   0,   8;
   48,  36,  12,  12,  12;
  288, 216,  72,  72,   0,  72;
		

Crossrefs

Programs

  • Maple
    T := proc (n, k) if n < k then 0 elif `mod`(n, 2) = 0 and `mod`(k, 2) = 0 then 2*factorial((1/2)*n)^2*binomial(n-k-1, (1/2)*n-(1/2)*k) elif `mod`(n, 2) = 0 and `mod`(k, 2) = 1 then 2*factorial((1/2)*n)^2*binomial(n-k-1, (1/2)*n-(1/2)*k+1/2) elif `mod`(n, 2) = 1 and `mod`(k, 2) = 0 then factorial((1/2)*n-1/2)*factorial((1/2)*n+1/2)*binomial(n-k, (1/2)*n-(1/2)*k-1/2) elif `mod`(n, 2) = 1 and k = n then factorial((1/2)*n-1/2)*factorial((1/2)*n+1/2) else factorial((1/2)*n-1/2)*factorial((1/2)*n+1/2)*binomial(n-k, (1/2)*n-(1/2)*k-1) end if end proc: for n to 10 do seq(T(n, k), k = 1 .. n) end do; # yields sequence in triangular form
  • Mathematica
    T[n0_?EvenQ, k_] := With[{n = n0/2}, 2 (n!)^2*Binomial[2 n - k - 1, n - Floor[k/2]]];
    T[n1_?OddQ, k0_?EvenQ] := With[{n = (n1 - 1)/2, k = k0/2}, n! (n + 1)! * Binomial[2 n - 2 k + 1, n - k] ];
    T[n1_?OddQ, k1_?OddQ] := With[{n = (n1 - 1)/2, k = (k1 - 1)/2}, n! (n+1)! * Binomial[2 n - 2 k, n - k - 1] ];
    T[n1_?OddQ, n1_?OddQ] := With[{n = (n1 - 1)/2}, n! (n + 1)!];
    Table[T[n, k], {n, 1, 10}, {k, 1, n}] // Flatten (* Jean-François Alcover, Nov 28 2017 *)

Formula

T(2n,k) = 2(n!)^2*binomial(2n-k-1, n-floor(k/2));
T(2n+1,2k) = n!(n+1)!*binomial(2n-2k+1, n-k);
T(2n+1,2k+1) = n!(n+1)!*binomial(2n-2k, n-k-1) if k < n;
T(2n+1,2n+1) = n!(n+1)!.