Problem 21 solution.