Lah numbers, sometimes referred to as Stirling numbers of the third kind, are coefficients of polynomial expansions expressing rising factorials in terms of falling factorials.

Unsigned Lah numbers count the number of ways a set of n elements can be partitioned into k non-empty linearly ordered subsets.

Lah numbers are closely related to Stirling numbers of the first & second kinds, and may be derived from them.

Lah numbers obey the identities and relations:

  L(n, 0), L(0, k) = 0   # for n, k > 0
  L(n, n) = 1
  L(n, 1) = n!
  L(n, k) =           ( n! * (n - 1)! ) / ( k! * (k - 1)! ) / (n - k)!      # For unsigned Lah numbers
     or
  L(n, k) = (-1)**n * ( n! * (n - 1)! ) / ( k! * (k - 1)! ) / (n - k)!      # For   signed Lah numbers

Task

 Write a routine (function, procedure, whatever) to find unsigned Lah numbers. There are several methods to generate unsigned Lah numbers. You are free to choose the most appropriate for your language. If your language has a built-in, or easily, publicly available library implementation, it is acceptable to use that.
 Using the routine, generate and show here, on this page, a table (or triangle) showing the unsigned Lah numbers, L(n, k), up to L(12, 12). it is optional to show the row / column for n == 0 and k == 0. It is optional to show places where L(n, k) == 0 (when k > n).
 If your language supports large integers, find and show here, on this page, the maximum value of L(n, k) where n == 100.


See also

 Wikipedia - Lah number
 OEIS:A105278 - Unsigned Lah numbers
 OEIS:A008297 - Signed Lah numbers


Related Tasks

 Stirling numbers of the first kind
 Stirling numbers of the second kind
 Bell numbers


BEGIN # calculate Lah numbers upto L( 12, 12 )                                      #
    PR precision 400 PR # set the precision for LONG LONG INT                       #
    # returns Lah Number L( n, k ), f must be a table of factorials to at least n   #
    PROC lah = ( INT n, k, []LONG LONG INT f )LONG LONG INT:
         IF   n = k          THEN 1
         ELIF n = 0 OR k = 0 THEN 0
         ELIF k = 1          THEN f[ n ]
         ELIF k > n          THEN 0
         ELSE
            # general case: ( n! * ( n - 1 )! ) / ( k! * ( k - 1 )! ) / ( n - k )!  #
            # we re-arrange the above to:                                           #
            #   (    n!      /    k! )      -- t1                                   #
            # * ( ( n - 1 )! / ( k - 1 )! ) -- t2                                   #
            # / ( n - k )!                                                          #
            LONG LONG INT t1 = f[ n     ] OVER f[ k     ];
            LONG LONG INT t2 = f[ n - 1 ] OVER f[ k - 1 ];
            ( t1 * t2 ) OVER f[ n - k ]
         FI # lah # ;
    INT max n       = 100; # max n for Lah Numbers                                  #
    INT max display =  12; # max n to display L( n, k ) values                      # 
    # table of factorials up to max n                                               #
    [ 1 : max n ]LONG LONG INT factorial;
    BEGIN
        LONG LONG INT f := 1;
        FOR i TO UPB factorial DO factorial[ i ] := f *:= i OD
    END;
    # show the Lah numbers                                                          #
    print( ( "Unsigned Lah numbers", newline ) );
    print( ( "n/k  0" ) );
    FOR i FROM 1 TO max display DO print( ( whole( i, -11 ) ) ) OD;
    print( ( newline ) );
    FOR n FROM 0 TO max display DO
        print( ( whole( n, -2 ) ) );
        print( ( whole( lah( n, 0, factorial ), -4 ) ) );
        FOR k FROM 1 TO n DO
            print( ( whole( lah( n, k, factorial ), -11 ) ) )
        OD;
        print( ( newline ) )
    OD;
    # maximum value of a Lah number for n = 100                                     #
    LONG LONG INT max 100 := 0;
    FOR k FROM 0 TO 100 DO
        LONG LONG INT lah n k = lah( 100, k, factorial );
        IF lah n k > max 100 THEN max 100 := lah n k FI
    OD;
    print( ( "maximum Lah number for n = 100: ", whole( max 100, 0 ), newline ) )
END