Code for problem 89.