Recursive solution for 9_1.