Problem5 first stab
Recursive based solution to problem6