Solution for Problem 8