Problem 40 complete