Code for problem 40A.
Code for problem 57C.