recursive solution to P0202