Code for problem 61.