Created a recursive and a iterative solution