Code for problem 57.