Edited and completed q07 with recursive function instead of iterative