Added iterative solution for problem 2.