CIS194/test.lhs

14 lines
245 B
Plaintext
Raw Normal View History

2016-03-25 15:54:43 +00:00
Compute the factorial of a given integer number n.
> fac :: Integer -> Integer
> fac 0 = 1
> fac n = n * fac(n-1)
Compute the sum of of all integer numbers from 1 to n.
> sumTo :: Integer -> Integer
> sumTo 0 = 0
> sumTo n = n + sumTo(n-1)