Solve Problem 40