Solution for problem 3.