# Recursion in mathematics

## The idea

In this lab try to implement a few of the classic mathematical functions that are expressed as recurrence relations.

You will need to write some code to call each of your methods and print its result.

## The functions

 factorial 0! = 1 n! = n*(n-1)!, when n > 0 Fibonacci Fibonacci really should not be implemented using recursion. Test with small numbers! Euclid’s GCD This is the ancient version. Euclid’s GCD This is the faster modern version that uses the modulus (`%` in Java) operator. Be sure to use the recursive definition. Squaring without multiplication 02 = 0 n2 = (n-1)2 + 2 n - 1, when n > 0 Slow exponentiation x0 = 1 xn = xn-1 x, when n > 0 better exponentiation x0 = 1 xn = xn/2 xn/2, when n > 0 and n is even xn = xn-1 x, when n is odd Mutually recursive odd & even even(0) = `true` even(n) = odd(n-1), when n > 0 odd(0) = `false` odd(n) = even(n-1), when n > 0 Combinations — n choose k There are are several different recursive definitions in the Wikipedia page for combinations. The Math is Fun page for Pascal’s triangle also presents these ideas with some very nice illustrations. Ackermann function This function is renown for how fast it grows. You must run it with small number.