Problem 5 iterative code

Developed iterative code to complement recursive code for Problem 5.