Code for problem 48.