Solution for problem 13