Code for problem 50.