Code for problem 53D.