Code for problem 59C.