Implement problem 5.