Code for problem 389E.