Solution for problem 50