def isa(li, i):
if 2 not in li and 3 not in li and 5 not in li:
return False
for j in li:
if j % 2 == 1 and j > 5 and j != i and j not in result: # 满足着条件都是Fasle 具体的我其实也忘了 只要j不在result里面其实就是False 什么原因 我真的忘了 但是你们做到这道题的时候可以想的到 主要是看这道题python题解太少了
return False
else:
return True
result = []
for i in range(1, 101):
if i == 1: # 1不讨论
result.append(i)
else:
a = []
for j in range(1, i + 1):
if i % j == 0:
a.append(j) # 就是把所有的因数放里面呗
# print(a)
if isa(a, i): # 就算判断符合不符合丑数的要求
result.append(i)
print(len(result))
12-17
959
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-11
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交