Solution for problem 5.