Solution for problem 15