“功能”对象没有属性“素数”

时间:2019-07-14 11:46:24

标签: python sieve-of-eratosthenes

尝试打印Eratosthenes Siege。 我明白了:

AttributeError: 'function' object has no attribute 'primes'

代码:

def get_numbers(n):
    primes = [] 
    for i in range(0,n+1):
        primes.append(i) 
    return primes

def erat(n):
    max = int(sqrt(n+1)) + 1
    list = get_numbers.primes
    for i in range(n+1, max):
        if i in list:
            for j in range(2, max):
                if list[i]%j == 0:
                    del list[i]
    return list

print(erat(n = 10))

0 个答案:

没有答案