Problem 40 Solution.