本帖最后由 元芳你怎么看 于 2016-4-12 15:22 编辑
| """ | | 欧拉计划501 | | 原题链接:https://projecteuler.net/problem=501 | | """ | | import math | | def Ghost_Euler_501(num): | | sumeight = 0 | | for i in range(1,num+1): | | counts = Ghost_Factor1(i) | | if counts == 8: | | sumeight = sumeight + 1 | | print("The eight factors of %d is %d" % (num,sumeight)) | | | | | | def Ghost_Factor(n): | | factors = [] | | for i in range(1,n+1): | | if n%i == 0: | | factors.append(i) | | | | return(factors) | | | | def Ghost_Factor1(n): | | counter = 0 | | sqrt_n = math.sqrt(n) | | for i in range(1,int(sqrt_n)): | | if n%i == 0: | | counter = counter + 2 | | if sqrt_n - int(sqrt_n) == 0: | | counter = counter + 1 | | else: | | counter = counter + 2 | | return(counter)COPY |
|