Problem 7 for edx class