Solution for problem 49