Adding solution for problem 23