Solution for problem 52