Simple recursive solution.