题目要求第n个丑数。所以对于中间结果不须要保存。

def Humble(index):
curHum = 1
M2 = 2; M3 = 3; M5 = 5
while index > 1:
curHum = min(min(M2, M3), M5)
while M2 <= curHum:
M2 *= 2
while M3 <= curHum:
M3 *= 3
while M5 <= curHum:
M5 *= 5
index -= 1
return curHum
04-14 05:55