Adding answer for problem 4