TPC 1 Recursive solution