added function for exercise 3
added iterative version of function for exercise 5
added recursive version of function for exercise 5