Add tail-recursive solution.