Adding solution for problem 21