Solution for Problem 2 and Problem 3