Help for this page

Select Code to Download


  1. or download this
    fact 0 = 1
    fact 1 = 1
    fact n | n < 0 = error "Negative factorial!"
           | otherwise = n * fact (n - 1)
    
  2. or download this
    fact 0 = 1
    fact 1 = 1
    ...
           | otherwise = g 1 n where
                g x 1 = x
                g x n' = g (x * n') (n' - 1)