We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
只包含2、3、5中的1个或多个因子的数称为丑数。
6 是丑数
14 =2*7 不是丑数
下一个丑数必定是数组中的某一个丑数A * 2、B * 3、C*5中最小的值
M2, 之前的丑数2都小于当前最大的丑数 之后的丑数2都大于当前最大的丑数
M3、M5
def getUglyNumber(index): if index < 1: return 0 res = [1] t2 = t3 = t5 = 0 nextdex = 1 while nextdex < index: minNum = min(res[t2] * 2, res[t3] * 3, res[t5] * 5) res.append(minNum) while res[t2] * 2 <= minNum: t2 += 1 while res[t3] * 2 <= minNum: t3 += 1 while res[t5] * 2 <= minNum: t5 += 1 nextdex += 1 return res[nextdex - 1] print(getUglyNumber(100)) ## 633825300114114700748351602688
按顺序把每个丑数放在数组中,求下一个丑数下一个丑数必定是数组中的某一个丑数A * 2, B * 3, C * 5 的中的最小值。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
只包含2、3、5中的1个或多个因子的数称为丑数。
6 是丑数
14 =2*7 不是丑数
下一个丑数必定是数组中的某一个丑数A * 2、B * 3、C*5中最小的值
M2, 之前的丑数2都小于当前最大的丑数
之后的丑数2都大于当前最大的丑数
M3、M5
按顺序把每个丑数放在数组中,求下一个丑数下一个丑数必定是数组中的某一个丑数A * 2, B * 3, C * 5 的中的最小值。
The text was updated successfully, but these errors were encountered: