*solved hw6 iteratively, need to solve with recursion