Ex1.37

Solution to 1.37; iterative version was a little bit tricky