P03 solution (nth)