Solved Problem30 in python.