@@ -207,9 +207,10 @@ fib Z = Z
207fib (S Z) = S Z
207fib (S Z) = S Z
208fib (S (S n)) = fib (S n) + fib n
208fib (S (S n)) = fib (S n) + fib n
210−--------------------------------------------------------------------------------
210+total fact : Nat -> Nat
211−-- GCD and LCM
211+fact Z = S Z
212−--------------------------------------------------------------------------------
212+fact (S Z) = S Z
213+fact (S n) = (S n) * fact n
214--------------------------------------------------------------------------------
215--------------------------------------------------------------------------------
215-- Division and modulus
216-- Division and modulus
@@ -245,6 +246,19 @@ log2 Z = Z
245log2 (S Z) = Z
246log2 (S Z) = Z
246log2 n = S (log2 (n `div` 2))
247log2 n = S (log2 (n `div` 2))
249+--------------------------------------------------------------------------------
251+--------------------------------------------------------------------------------
253+gcd : Nat -> Nat -> Nat
255+gcd a b = gcd b (a `mod` b)
257+total lcm : Nat -> Nat -> Nat
260+lcm x y = div (x * y) (gcd x y)
248--------------------------------------------------------------------------------
262--------------------------------------------------------------------------------
249-- Properties
263-- Properties
250--------------------------------------------------------------------------------
264--------------------------------------------------------------------------------