Code for problem 335A.