Haskell by Example: Recursion

original

see also The Evolution of a Haskell Programmer.

fact :: Int -> Int
fact 0 = 1
fact n = n * fact (n-1)

main = print $ fact 7
$ runhaskell recursion.hs
5040
back to index