Code for problem 27.