Code for problem 41A.