Code for problem 23.