Adding solution for problem 45.