标签:面试题 algorithm humble python
题目要求第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
【剑指offer】q34:丑数,布布扣,bubuko.com
标签:面试题 algorithm humble python
原文地址:http://blog.csdn.net/shiquxinkong/article/details/36520665