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.

Previous Showing 41-50 of 122 results. Next

A357611 A refinement of the Mahonian numbers (canonical ordering).

Original entry on oeis.org

1, 1, 1, 1, 2, 2, 1, 1, 3, 5, 3, 3, 5, 3, 1, 1, 4, 9, 9, 6, 4, 16, 11, 11, 16, 4, 6, 9, 9, 4, 1, 1, 5, 14, 19, 10, 14, 35, 5, 40, 26, 19, 61, 10, 40, 26, 35, 35, 26, 40, 10, 61, 19, 26, 40, 5, 35, 14, 10, 19, 14, 5, 1
Offset: 1

Views

Author

Denis K. Sunko, Oct 06 2022

Keywords

Comments

Let T(N,d) be a Mahonian number.
(1) Find all partitions k(1) >= k(2) >= ... >= k(N) = 0 of the number d with at most N-1 parts, such that k(i) - k(i+1) <= 1 and k(N) = 0.
(2) For each such partition, draw a ribbon Young diagram with N boxes at matrix (row-column) coordinates (k(i), k(i) + i - 1), i = 1, ..., N.
(3) For each ribbon diagram, count all standard Young skew tableaux.
The numbers under (3) will add up to T(N,d), as proven in the cited reference. These refinements appear consecutively as subsequences in the sequence, ordered by increasing N and decreasing d from N(N-1)/2 to 0 for each N. The ordering within each subsequence is reverse-lexicographic by the partitions (1), i.e., from the largest k(1) down.
This ordering is called canonical because it corresponds to the ordering of generating polynomials (from the highest power down). Because of certain symmetries in the sequence (cf. the example), it is the same as increasing d from 0 to N(N-1)/2 and ordering the partitions lexicographically. For the converse convention, cf. A356802.
The sums of rows (3) are A008302. Because the latter is itself a triangle, arranged in the (N, d) plane, the present sequence is actually three-dimensional: each number in the triangle A008302 can be replaced by the row numbers (3), each of which is thus coordinatized by (N, d, m), the last coordinate being its position in the row.
The range of the m coordinate is the number of partitions satisfying the constraint (1). It is proven in the cited reference to be equal to the coefficient of q^d in the q-binomial theorem: coeff[q^d] Product_{k=1..N-1} (1 + q^k).
This is a different ordering of A060351 and A335845 because every standard Young ribbon diagram of a given shape corresponds to a permutation with a given descent set, see the example. - Andrey Zabolotskiy, Oct 08 2024
However, the orderings in A060351 and A335845 cannot be considered a refinement of Mahonians because the terms adding to a single Mahonian do not appear consecutively in them, beginning with N=5 in the example. - Denis K. Sunko, Dec 27 2024

Examples

			The first nontrivial terms in the sequence are a(11) = a(12) = 3, corresponding to the refinement T(4, 3) = 6 = 3 + 3. The terms from a(1) to a(10) are the Mahonian numbers themselves, because the refinement is trivial for them (there is only one partition satisfying the given constraints).
Specifically, the row T(N, d) with N=4 and d=3 corresponds to Young ribbon diagrams with 4 cells such that the sum of the row indices of cells (with the top row having index 0) is equal to 3. There are two such diagrams:
  (A) ##   (B)   #
      #        ###
      #
3 = 2+1+0+0 = 1+1+1+0 are the corresponding integer partitions, which are referenced in the Comments section, listed in the lexicographic order. These partitions have descent sets (indices of elements followed by a smaller element) {1,2} and {3}, respectively (they both sum up to 3, necessarily).
Diagram (A) can be filled in as a standard Young diagram in 3 ways:
   12   14   13
   3    2    2
   4    3    4
Diagram (B) can be filled in in 3 ways, too:
    2    3    1
  134  124  234
Thus, the row T(4, 3) is 3, 3. These standard Young ribbon diagrams, when read bottom-left to top-right, become permutations of 1234 with major index 3, namely 4312, 3214, 4213 with the descent set {1,2} and 1342, 1243, 2341 with the descent set {3} (same descent sets as those of the corresponding partitions!).
The data in triangular form are:
N, d
1, 0    1,
2, 1    1,
   0    1,
3, 3    1,
   2    2,
   1    2,
   0    1,
4, 6    1,
   5    3,
   4    5,
   3    3, 3,
   2    5,
   1    3,
   0    1,
5,10    1,
   9    4,
   8    9,
   7    9, 6,
   6    4, 16,
   5    11, 11,
   4    16, 4,
   3    6, 9,
   2    9,
   1    4,
   0    1,
6,15    1,
  14    5,
  13    14,
  12    19, 10,
  11    14, 35,
  10    5, 40, 26,
   9    19, 61, 10,
   8    40, 26, 35,
   7    35, 26, 40,
   6    10, 61, 19,
   5    26, 40, 5,
   4    35, 14,
   3    10, 19,
   2    14,
   1    5,
   0    1
One can check the generating function for the number of terms in a row, e.g., for N = 4: (1 + q)(1 + q^2)(1 + q^3) = q^6 + q^5 + q^4 + 2q^3 + q^2 + q + 1.
		

Crossrefs

Programs

  • SageMath
    def possible_classes(n, degree):
        for stub in Partitions(degree, max_part = n-1, max_length = n-1, min_slope = -1):
            cls = list(stub)
            if cls:
                if cls[-1] < 2:
                    yield cls + (n - len(cls)) * [0]
            else:
                yield n * [0]
    #
    def count_tableaux(cls):
        inner = []
        outer = [1]
        right = 1
        previous_part = cls[0]
        for part in cls[1:]:
            if part == previous_part:
                right += 1
                outer[-1] = right
            else:
                previous_part = part
                outer += [right]
                if right > 1:
                    inner += [right-1]
        outer.reverse()
        inner.reverse()
        return StandardSkewTableaux([outer, inner]).cardinality()
    #
    def refine_mahonian(N, d, total = False):
        """
        Eq. (50) in DOI:10.48550/arXiv.2209.02523 was
        generated by the call refine_mahonian(8, 16, True).
        """
        res = []
        for cls in possible_classes(N,d):
            res += [count_tableaux(cls)]
        if total:
            res = (res, sum(res)) # the sum should be T(N, d)
        return res
    #
    def refine_mahonians_table(Nmax, total = False, canonical = True):
        res = []
        for N in range(1, Nmax + 1):
            r = []
            if canonical:
                ordering = range(N * (N - 1) // 2, -1, -1)
            else:
                ordering = range(N * (N - 1) // 2 + 1)
            for d in ordering:
                r += [refine_mahonian(N, d, total = total)]
            res += [r]
        return res
    #
    def refine_mahonians(Nmax, canonical = True):
        """
        Nmax = 6, canonical = True  gives seq. A357611 in the OEIS.
        Nmax = 6, canonical = False gives seq. A356802 in the OEIS.
        """
        return flatten(refine_mahonians_table(Nmax, total = False, canonical = canonical))
    
  • SageMath
    from collections import Counter
    def part(n, descents):
        r = tuple(sum(i <= d for d in descents) for i in (1..n))
        return (sum(r), r) # replace sum(r) by -sum(r) to obtain A356802 instead
    def row(n):
        return [x[1] for x in sorted(Counter((part(n, p.descents()) for p in Permutations(n))).items())]
    print(sum([row(n) for n in (1..6)], [])) # Andrey Zabolotskiy, Oct 19 2024

A005287 Number of permutations of [n] with four inversions.

Original entry on oeis.org

5, 20, 49, 98, 174, 285, 440, 649, 923, 1274, 1715, 2260, 2924, 3723, 4674, 5795, 7105, 8624, 10373, 12374, 14650, 17225, 20124, 23373, 26999, 31030, 35495, 40424, 45848, 51799, 58310, 65415, 73149, 81548, 90649, 100490, 111110, 122549, 134848, 148049
Offset: 4

Views

Author

Keywords

Examples

			[2, 4, 3, 1], [3, 2, 4, 1], [3, 4, 1, 2], [4, 1, 3, 2], [4, 2, 1, 3] have 4 inversions.
		

References

  • L. Comtet, Advanced Combinatorics, Reidel, 1974, p. 255, #2, b(n,4).
  • F. N. David, M. G. Kendall and D. E. Barton, Symmetric Function and Allied Tables, Cambridge, 1966, p. 241.
  • R. K. Guy, personal communication.
  • E. Netto, Lehrbuch der Combinatorik. 2nd ed., Teubner, Leipzig, 1927, p. 96.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • R. P. Stanley, Enumerative Combinatorics, Cambridge, Vol. 1, 1999; see Exercise 1.30, p. 49.

Crossrefs

Programs

  • Magma
    [n*(n+1)*(n^2+n-14)/24: n in [4..50]]; // Vincenzo Librandi, Jul 17 2011
  • Maple
    [seq(binomial(n,4)+binomial(n,3)-binomial(n,2), n=5..43)]; # Zerinvary Lajos, Jul 23 2006
  • Mathematica
    CoefficientList[Series[(z^4 - 3*z^3 + z^2 + 5*z - 5)/(z - 1)^5, {z, 0, 100}], z] (* Vladimir Joseph Stephan Orlovsky, Jul 16 2011 *)
    LinearRecurrence[{5,-10,10,-5,1},{5,20,49,98,174},40] (* Harvey P. Dale, Aug 25 2016 *)
  • PARI
    a(n)=if(n<4,0,n*(n+1)*(n^2+n-14)/24)
    

Formula

a(n) = n*(n+1)*(n^2+n-14)/24.
G.f.: x^4*(-5 + 5*x + x^2 - 3*x^3 + x^4) / (x-1)^5. - Simon Plouffe in his 1992 dissertation
a(n) = binomial(n+1,4) + binomial(n+1,3) - binomial(n+1,2). - Zerinvary Lajos, Jul 23 2006

A129276 Triangle, read by rows, where T(n,k) is the coefficient of q^(nk-k) in the squared q-factorial of n.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 8, 8, 1, 1, 42, 106, 42, 1, 1, 241, 1558, 1558, 241, 1, 1, 1444, 23589, 53612, 23589, 1444, 1, 1, 8867, 360499, 1747433, 1747433, 360499, 8867, 1, 1, 55320, 5530445, 54794622, 111482424, 54794622, 5530445, 55320, 1
Offset: 0

Views

Author

Paul D. Hanna, Apr 07 2007

Keywords

Comments

Dual triangle is A129274.
Central terms form a bisection of A127728.

Examples

			Definition of q-factorial of n:
faq(n,q) = Product_{k=1..n} (1-q^k)/(1-q) for n>0, with faq(0,q)=1.
Obtain row 4 from coefficients in the squared q-factorial of 4:
faq(4,q)^2 = 1*(1 + q)^2*(1 + q + q^2)^2*(1 + q + q^2 + q^3)^2
= (1 + 3*q + 5*q^2 + 6*q^3 + 5*q^4 + 3*q^5 + q^6)^2;
the resulting coefficients of q are:
[(1), 6, 19, (42), 71, 96, (106), 96, 71, (42), 19, 6, (1)],
where the terms enclosed in parenthesis form row 4.
Triangle begins:
1;
1, 1;
1, 2, 1;
1, 8, 8, 1;
1, 42, 106, 42, 1;
1, 241, 1558, 1558, 241, 1;
1, 1444, 23589, 53612, 23589, 1444, 1;
1, 8867, 360499, 1747433, 1747433, 360499, 8867, 1;
1, 55320, 5530445, 54794622, 111482424, 54794622, 5530445, 55320, 1; ...
		

Crossrefs

Cf. A129277 (column 1), A129278 (column 2); A127728 (central terms), related triangles: A129274, A128564, A008302 (Mahonian numbers).

Programs

  • Mathematica
    faq[n_, q_] := Product[(1-q^k)/(1-q), {k, 1, n}]; t[0, 0] = t[1, 0] = t[1, 1] = 1; t[n_, k_] := SeriesCoefficient[faq[n, q]^2, {q, 0, (n-1)*k}]; Table[t[n, k], {n, 0, 8}, {k, 0, n}] // Flatten (* Jean-François Alcover, Nov 26 2013 *)
  • PARI
    T(n,k)=if(n==0,1,polcoeff(prod(i=1,n,(1-x^i)/(1-x))^2,(n-1)*k))

Formula

T(n,k) = [q^(nk-k)] Product_{i=1..n} { (1-q^i)/(1-q) }^2 for n>0, with T(0,0)=1.
Row sums = (n!)^2/(n-1) for n>=2.

A139365 Array of digit sums of factorial representation of numbers 0,1,...,n!-1 for n >= 1.

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 1, 2, 2, 3, 0, 1, 1, 2, 2, 3, 1, 2, 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, 3, 4, 4, 5, 5, 6, 0, 1, 1, 2, 2, 3, 1, 2, 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, 3, 4, 4, 5, 5, 6, 1, 2, 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, 3, 4, 4, 5, 5, 6, 4, 5, 5, 6, 6, 7, 2, 3, 3, 4, 4, 5, 3, 4, 4, 5, 5, 6, 4, 5, 5, 6, 6, 7, 5, 6, 6, 7, 7
Offset: 0

Views

Author

Wolfdieter Lang, May 21 2008

Keywords

Comments

The row lengths sequence is A000142 (factorials).
When the factorial representation is read as (D. N.) Lehmer code for permutations of n objects then the digit sums in row n count the inversions of the permutations arranged in lexicographic order.
Row n is the first n! terms of A034968. - Franklin T. Adams-Watters, May 13 2009

Examples

			n=3: The Lehmer codes for the permutations of {1,2,3} are [0,0,0], [0,1,0], [1,0,0], [1,1,0], [2,0,0] and [2,1,0]. These are the factorial representations for 0,1,...,5=3!-1. Therefore row n=3 has the digit sums 0,1,1,2,2,3, the number of inversions of the permutations [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2] and [3,2,1] (lexicographic order).
Triangle begins:
  0;
  0;
  0, 1;
  0, 1, 1, 2, 2, 3;
  0, 1, 1, 2, 2, 3, 1, 2, 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, 3, 4, 4, 5, 5, 6;
  ...
		

Crossrefs

Cf. A008302.
Row sums give A001809.

Programs

  • Mathematica
    nn = 5; m = 1; While[Factorial@ m < nn! - 1, m++]; m; Table[Total@ IntegerDigits[k, MixedRadix[Reverse@ Range[2, m]]], {n, 0, 5}, {k, 0, n! - 1}] // Flatten (* Version 10.2, or *)
    f[n_] := Block[{a = {{0, n}}}, Do[AppendTo[a, {First@ #, Last@ #} &@ QuotientRemainder[a[[-1, -1]], Times @@ Range[# - i]]], {i, 0, #}] &@ NestWhile[# + 1 &, 0, Times @@ Range[# + 1] <= n &]; Most@ Rest[a][[All, 1]]]; Table[Total@ f@ k, {n, 0, 5}, {k, 0, n! - 1}] // Flatten (* Michael De Vlieger, Aug 29 2016 *)

Formula

Row n >= 1: sum(facrep(n,m)[n-j],j=1..n), m=0,1,...,n!-1, with the factorial representation facrep(n,m) of m for given n.
T(n,n!-1) = A161680(n). - Alois P. Heinz, Jan 20 2025

Extensions

Zeroth row added by Franklin T. Adams-Watters, May 13 2009

A274887 Triangle read by rows: coefficients of the q-factorial.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 2, 1, 1, 3, 5, 6, 5, 3, 1, 1, 4, 9, 15, 20, 22, 20, 15, 9, 4, 1, 1, 5, 14, 29, 49, 71, 90, 101, 101, 90, 71, 49, 29, 14, 5, 1, 1, 6, 20, 49, 98, 169, 259, 359, 455, 531, 573, 573, 531, 455, 359, 259, 169, 98, 49, 20, 6, 1
Offset: 0

Views

Author

Peter Luschny, Jul 19 2016

Keywords

Comments

The main entry for this sequence is A008302 (Mahonian numbers).
q-factorial(n) is a univariate polynomial over the integers with degree n*(n-1)/2.
Evaluated at q=1 the q-factorial(n) gives the factorial A000142(n).

Examples

			The polynomials start:
[0] 1
[1] 1
[2] q + 1
[3] (q + 1) * (q^2 + q + 1)
[4] (q + 1)^2 * (q^2 + 1) * (q^2 + q + 1)
[5] (q + 1)^2 * (q^2 + 1) * (q^2 + q + 1) * (q^4 + q^3 + q^2 + q + 1)
The triangle starts:
[1]
[1]
[1, 1]
[1, 2, 2, 1]
[1, 3, 5, 6, 5, 3, 1]
[1, 4, 9, 15, 20, 22, 20, 15, 9, 4, 1]
[1, 5, 14, 29, 49, 71, 90, 101, 101, 90, 71, 49, 29, 14, 5, 1]
		

Crossrefs

Cf. A008302 (the same for all n > 0), A000142 (row sums), A063746 (q-central_binomial), A129175 (q-Catalan), A274886 (q-extended_Catalan), A274888 (q-swing_factorial), A275216 (q-binomial), A275215 (q-Narayana).

Programs

  • Magma
    B:= func< n,x | n eq 0 select 1 else (&*[1-x^j: j in [1..n]])/(1-x)^n >;
    R:=PowerSeriesRing(Integers(), 30);
    [Coefficients(R!( B(n,x) )): n in [0..9]]; // G. C. Greubel, May 22 2019
    
  • Mathematica
    Table[CoefficientList[QFactorial[n,q]//FunctionExpand, q], {n,0,9} ]//Flatten
  • PARI
    for(n=0, 8, print1(Vec(if(n==0, 1, prod(j=1, n, 1-x^j)/(1-x)^n)), ", "); print(); ) \\ G. C. Greubel, May 23 2019
  • Sage
    from sage.combinat.q_analogues import q_factorial
    for n in (0..5): print(q_factorial(n).list())
    

Formula

a(n) = A008302(n) for all n > 0. - M. F. Hasler, Jan 06 2024

A289778 Number T(n,k) of reduced decompositions for all permutations of [n] with exactly k inversions; triangle T(n,k), n>=0, 0<=k<=n*(n-1)/2, read by rows.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 2, 2, 1, 3, 6, 10, 14, 16, 16, 1, 4, 12, 30, 68, 132, 252, 412, 614, 768, 768, 1, 5, 20, 68, 210, 588, 1540, 3778, 8768, 19402, 40284, 78276, 137236, 219362, 292864, 292864, 1, 6, 30, 130, 512, 1864, 6340, 20472, 62770, 184748, 521272, 1428932
Offset: 0

Views

Author

Alois P. Heinz, Jul 12 2017

Keywords

Examples

			Triangle T(n,k) begins:
  1;
  1;
  1, 1;
  1, 2,  2,  2;
  1, 3,  6, 10, 14,  16,  16;
  1, 4, 12, 30, 68, 132, 252, 412, 614, 768, 768;
  ...
		

Crossrefs

Row sums give A246865.

Formula

T(n,n*(n-1)/2) = A005118(n).

A060701 Table by antidiagonals of Mahonian numbers T(n,k): permutations of n letters with k inversions.

Original entry on oeis.org

1, 0, 1, 0, 1, 1, 0, 0, 2, 1, 0, 0, 2, 3, 1, 0, 0, 1, 5, 4, 1, 0, 0, 0, 6, 9, 5, 1, 0, 0, 0, 5, 15, 14, 6, 1, 0, 0, 0, 3, 20, 29, 20, 7, 1, 0, 0, 0, 1, 22, 49, 49, 27, 8, 1, 0, 0, 0, 0, 20, 71, 98, 76, 35, 9, 1, 0, 0, 0, 0, 15, 90, 169, 174, 111, 44, 10, 1, 0, 0, 0, 0, 9, 101, 259, 343, 285
Offset: 0

Views

Author

Henry Bottomley, Apr 25 2001

Keywords

Examples

			1;
0,1;
0,1,1;
0,0,2,1;
0,0,2,3,1;
0,0,1,5,4,1;
0,0,0,6,9,5,1; ...
[1, 4, 2, 3], [1, 3, 4, 2], [2, 1, 4, 3], [2, 3, 1, 4], [3, 1, 2, 4] have 2 inversions so T(4, 2)=5.
		

References

  • R. P. Stanley, Enumerative Combinatorics, Cambridge, Vol. 1, 1999; see Corollary 1.3.10, p. 21.

Crossrefs

A008302 is the main entry for these numbers. Columns include A000012, A000027, A000096, A005286, A005287, A005288. Diagonals include A000707, A001892, A001893, A001894, A005283, A005284, A005285.

Programs

  • PARI
    T(n,k)=polcoeff(prod(j=1,n-1,sum(i=0,j,x^i)),k)

Formula

T(n, k)=sum_{j=0..n}[T(n-1, k-j)].
Product (1+x+...+x^k), k=1..n-1 = Sum T(n, k)x^k, k=0..n(n-1)/2.

Extensions

Additional comments from Michael Somos, Jun 23 2002.

A128565 Column 1 of triangle A128564; a(n) equals the number of permutations of {1..n+2} with [n/2+1] inversions for n>=0.

Original entry on oeis.org

1, 2, 5, 9, 29, 49, 174, 285, 1068, 1717, 6655, 10569, 41926, 66013, 266338, 416687, 1703027, 2651355, 10947079, 16976806, 70673825, 109256095, 457927079, 706071989, 2976282415, 4579020513, 19395654894, 29784426945, 126688273871, 194231327451, 829176461458
Offset: 0

Views

Author

Paul D. Hanna, Mar 12 2007

Keywords

Crossrefs

Cf. A008302 (Mahonian numbers); A128564 (triangle), A128566 (column 2).

Programs

  • PARI
    {a(n)=polcoeff(prod(j=1, n+2, (1-q^j)/(1-q)),(n+2)\2,q)}

Formula

a(n) = A008302(n+2,[n/2+1]) = coefficient of q^[n/2+1] in the q-factorial of n+2 for n>=0.

A129274 Triangle, read by rows, where T(n,k) is the coefficient of q^(nk+k) in the squared q-factorial of n+1.

Original entry on oeis.org

1, 1, 1, 1, 10, 1, 1, 71, 71, 1, 1, 474, 1930, 474, 1, 1, 3103, 40096, 40096, 3103, 1, 1, 20190, 739929, 2108560, 739929, 20190, 1, 1, 131204, 12836959, 88638236, 88638236, 12836959, 131204, 1, 1, 853176, 215022825, 3286786158, 7625997280
Offset: 0

Views

Author

Paul D. Hanna, Apr 07 2007

Keywords

Comments

Row sums equal A010790(n) = n!*(n+1)! for n>=0. Central terms form a bisection of A127728. Dual triangle is A129276.

Examples

			Definition of q-factorial of n:
faq(n,q) = Product_{k=1..n} (1-q^k)/(1-q) for n>0, with faq(0,q)=1.
Obtain row 3 from coefficients in the squared q-factorial of 4:
faq(4,q)^2 = 1*(1 + q)^2*(1 + q + q^2)^2*(1 + q + q^2 + q^3)^2
= (1 + 3*q + 5*q^2 + 6*q^3 + 5*q^4 + 3*q^5 + q^6)^2;
the resulting coefficients of q are:
[(1), 6, 19, 42, (71), 96, 106, 96, (71), 42, 19, 6, (1)],
where the terms enclosed in parenthesis form row 3.
Triangle begins:
1;
1, 1;
1, 10, 1;
1, 71, 71, 1;
1, 474, 1930, 474, 1;
1, 3103, 40096, 40096, 3103, 1;
1, 20190, 739929, 2108560, 739929, 20190, 1;
1, 131204, 12836959, 88638236, 88638236, 12836959, 131204, 1;
1, 853176, 215022825, 3286786158, 7625997280, 3286786158, 215022825, 853176, 1; ...
		

Crossrefs

Cf. A129275 (column 1); A127728 (central terms), A010790 (row sums); related triangles: A129276, A128564, A008302 (Mahonian numbers).

Programs

  • PARI
    T(n,k)=polcoeff(prod(i=1,n+1,(1-x^i)/(1-x))^2,(n+1)*k)

Formula

T(n,k) = [q^(nk+k)] Product_{i=1..n+1} { (1-q^i)/(1-q) }^2.

A161169 Triangle read by rows: T(n,k) = number of permutations of {1..n} with at most k inversions.

Original entry on oeis.org

1, 1, 1, 2, 1, 3, 5, 6, 1, 4, 9, 15, 20, 23, 24, 1, 5, 14, 29, 49, 71, 91, 106, 115, 119, 120, 1, 6, 20, 49, 98, 169, 259, 360, 461, 551, 622, 671, 700, 714, 719, 720, 1, 7, 27, 76, 174, 343, 602, 961, 1416, 1947, 2520, 3093, 3624, 4079, 4438, 4697, 4866, 4964, 5013
Offset: 0

Views

Author

Shreevatsa R, Jun 04 2009

Keywords

Comments

T(n,k) is also the number of permutations with Kendall tau distance ("bubble-sort distance") to the identity permutation being at most k. This is the number of swaps performed by the bubble-sort algorithm to sort the sequence.
The above only gives T(n,k) for k<=n(n-1)/2, but T(n,k)=n! for all k>=n(n-1)/2.

Examples

			Triangle begins:
  1;
  1;
  1, 2;
  1, 3,  5,  6;
  1, 4,  9, 15, 20,  23,  24;
  1, 5, 14, 29, 49,  71,  91, 106, 115, 119, 120;
  1, 6, 20, 49, 98, 169, 259, 360, 461, 551, 622, 671, 700, 714, 719, 720;
  ...
T(3,2)=5 because there are 5 permutations of {1,2,3} with at most 2 inversions: (1,2,3) with 0 inversions, (1,3,2), (2,1,3) with 1 inversion each, (2,3,1), (3,1,2) with 2 inversions each.
T(n,0)=1 because there is exactly 1 permutation (the identity permutation) with no inversions,
T(n,k) = n! for all k >= n(n-1)/2 because all permutations have at most n(n-1)/2 inversions.
		

Crossrefs

Partial sums of A008302.

Programs

  • Python
    ct = {(0,0): 1}
    def c(n,k):
        if k<0: return 0
        k = min(k, n*(n-1)/2)
        if (n, k) in ct: return ct[(n, k)]
        ct[(n, k)] = c(n, k-1) + c(n-1, k) - c(n-1, k-n)
        return ct[(n, k)]

Formula

T(n,k) = Sum_{i s.t. n-i<=k} T(n-1, k-(n-i));
T(n,k) = Sum_{i=max(1,n-k)..n} T(n-1, k-n+i);
T(n,k) = Sum_{j=max(k-n+1,0)..n} T(n-1, j).
T(n,k) = T(n,k-1) + T(n-1,k) - T(n-1,k-n), taking T(n,k)=0 for k<0.
Also, T(n,k) = n! - T(n, n(n-1)/2-k-1).
For k<=n, T(n,k) = A008302(n+1,k).
G.f.: (1/(1-x))*Product_{j=1..n} (1-x^j)/(1-x) = Sum_{k>=0} T(n,k) x^k. - Alejandro H. Morales, Apr 04 2024
Previous Showing 41-50 of 122 results. Next