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.

A217922 Triangle read by rows: labeled trees counted by improper edges.

Original entry on oeis.org

1, 1, 2, 1, 6, 7, 3, 24, 46, 40, 15, 120, 326, 430, 315, 105, 720, 2556, 4536, 4900, 3150, 945, 5040, 22212, 49644, 70588, 66150, 38115, 10395, 40320, 212976, 574848, 1011500, 1235080, 1032570, 540540, 135135
Offset: 1

Views

Author

David Callan, Oct 14 2012

Keywords

Comments

T(n,k) is the number of labeled trees on [n], rooted at 1, with k improper edges, for n >= 1, k >= 0. See Zeng link for definition of improper edge.

Examples

			Triangle begins:
  \ k  0....1....2....3....4......
  n
  1 |..1
  2 |..1
  3 |..2....1
  4 |..6....7....3
  5 |.24...46...40....15
  6 |120..326..430...315...105
T(4,2) = 3 because we have 1->3->4->2, 1->4->2->3, 1->4->3->2, in each of which the last 2 edges are improper.
		

Crossrefs

Row sums are A000272.

Programs

  • Magma
    function T(n,k) // T = A217922
      if k lt 0 or k gt n-2 then return 0;
      elif k eq 0 then return Factorial(n-1);
      else return (n-1)*T(n-1,k) + (n+k-3)*T(n-1,k-1);
      end if;
    end function;
    [1] cat [T(n,k): k in [0..n-2], n in [2..12]]; // G. C. Greubel, Jan 10 2025
  • Mathematica
    T[n_, k_]:= T[n,k]= If[k<0 || k>n-2, 0, If[k==0, (n-1)!, (n-1)*T[n-1,k] + (n+k-3)*T[n-1, k-1]]];
    Join[{1}, Table[T[n,k], {n,12}, {k,0,n-2}]//Flatten] (* modified by G. C. Greubel, May 07 2019 *)
  • SageMath
    def T(n, k):
        if k==0: return factorial(n-1)
        elif (k<0 or k > n-2): return 0
        else: return (n-1)*T(n-1, k) + (n+k-3)* T(n-1, k-1)
    flatten([1] + [[T(n, k) for k in (0..n-2)] for n in (2..12)]) # G. C. Greubel, May 07 2019
    

Formula

T(n, k) = (n-1)*T(n-1, k) + (n+k-3)*T(n-1, k-1), for 1 <= k <= n-2, with T(n, 0) = (n-1)!. - G. C. Greubel, Jan 10 2025