3 people like it.

Factorial

Factorial versus tail recursion

1: 
2: 
3: 
4: 
5: 
6: 
let factorial x = 
    let rec util(value, acc) = 
        match value with
        |0 | 1 -> acc
        | _    -> util(value - 1, acc * value)
    util(x,1)
val factorial : x:int -> int

Full name: Script.factorial
val x : int
val util : (int * int -> int)
val value : int
val acc : int
Raw view New version

More information

Link:http://fssnip.net/fk
Posted:6 years ago
Author:Laco
Tags: tail recursion , factorial