Solution for the problem 7