solved problem 11 with a nicer recursion