Adding answer to problem 4