Solution for Problem 4