Solution for problem 45