Code for problem 56.