Factorial in F#

Example for versions fsharp 2.0.0

This example uses recursive definition of factorial, expressed in procedural paradigm.

factorial defines the actual factorial-calculating routine, and printFact defines the routine that outputs calculated factorials in required format.

let rec factorial n =
    match n with
    | 0 -> 1
    | _ -> n * factorial (n - 1)

let rec printFact n  =
    match n with 
    | 0 -> printfn "0! = 1"
    | _ -> printFact (n-1)
           printfn "%d! = %d"  n (factorial (n))
           
printFact(16)