Code for problem 38D.