Initial attempt for Problem 11 using recursion