Code for problem 35.