Solution for problem 25