Solution for Problem 7