Problem 39, 40 solution and 41, 42 start