Code for problem 17A.