|
发表于 2020-2-1 18:19:30
|
显示全部楼层
版主,我测了一下 这个极快 应该比其他鱼油得快一些。来测测吧
- import math
- def fun321(n):
- def split(n):
- oushu = 1
- jishu = 1
- while n > 1:
- if n % 2 ==0:
- oushu = oushu * 2
- n = n // 2
- else:
- break
- jishu = n
- return (jishu,oushu)
- def yueshu(n):
- res = []
- index = 1
- gate =math.floor(n ** (1/2))
- while index < gate:
- if n % index == 0:
- res.append(index)
- res.append(n//index)
- else:
- pass
- index += 1
- if n % gate==0:
- res.append(gate)
- return res
-
- maxGate = (2*n)**(1/2)
- jishu,oushu = split(2*n)
- jiyueshu = yueshu(jishu)
- result = 0
- for each in jiyueshu:
- if each < maxGate:
- result += 1
- if oushu * each < maxGate:
- result += 1
- else:
- pass
- else:
- pass
-
- return result
复制代码 |
评分
-
查看全部评分
|