小编Jes*_*eff的帖子

有没有办法避免这种内存错误?

我目前正在解决Project Euler上的问题,到目前为止,我已经提出了这个问题的代码.

from itertools import combinations
import time

def findanums(n):
    l = []
    for i in range(1, n + 1):
        s = []
        for j in range(1, i):
            if i % j == 0:
                s.append(j)
        if sum(s) > i:
            l.append(i)
    return l

start = time.time() #start time

limit = 28123

anums = findanums(limit + 1) #abundant numbers (1..limit)
print "done finding abundants", time.time() - start

pairs = combinations(anums, 2)
print "done finding combinations", time.time() - start

sums = map(lambda x: …
Run Code Online (Sandbox Code Playgroud)

python memory pypy

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

memory ×1

pypy ×1

python ×1