Adding solution to Problem 8.