Adding solution for problem 16