How to resolve the algorithm Lah numbers step by step in the F# programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Lah numbers step by step in the F# programming language

Table of Contents

Problem Statement

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:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Lah numbers step by step in the F# programming language

Source code in the fsharp programming language

// Lah numbers. Nigel Galloway: January 3rd., 2023
let fact(n:int)=let rec fact=function n when n=0I->1I |n->n*fact(n-1I) in fact(bigint n)
let rec lah=function (_,0)|(0,_)->0I |(n,1)->fact n |(n,g) when n=g->1I |(n,g)->((fact n)*(fact(n-1)))/((fact g)*(fact(g-1)))/(fact(n-g))
for n in {0..12} do (for g in {0..n} do printf $"%A{lah(n,g)} "); printfn ""
printfn $"\n\n%A{seq{for n in 1..99->lah(100,n)}|>Seq.max}"


  

You may also check:How to resolve the algorithm Lucas-Lehmer test step by step in the R programming language
You may also check:How to resolve the algorithm Tic-tac-toe step by step in the JavaScript programming language
You may also check:How to resolve the algorithm I before E except after C step by step in the Wren programming language
You may also check:How to resolve the algorithm Create an HTML table step by step in the Scala programming language
You may also check:How to resolve the algorithm Non-decimal radices/Output step by step in the Arturo programming language