Code for problem 120.