Code for problem 115.