Code for problem 42.
Code for problem 39.