Solution for problem 17