def e095_slow(top = 10**6): p = primesd(top) maxdict = {} aset = set() for i in range(2,top): if i%10**3==0:print(i,time()-t) if p.get(i):continue adict = {} tmp = i while True: tmp = sum(all_factors(tmp))-tmp if p.get(tmp) or tmp>=top:break elif adict.get(tmp):break elif tmp==i: adict[i] = 1 if len(adict)>len(maxdict): maxdict = adict print('i:',i,' max:',len(maxdict),' time:',time()-t) print(maxdict) break else:adict[tmp]=1 if i ==14316:print(i) return min(maxdict.keys())
def e095_slow(top=10**6): p = primesd(top) maxdict = {} aset = set() for i in range(2, top): if i % 10**3 == 0: print(i, time() - t) if p.get(i): continue adict = {} tmp = i while True: tmp = sum(all_factors(tmp)) - tmp if p.get(tmp) or tmp >= top: break elif adict.get(tmp): break elif tmp == i: adict[i] = 1 if len(adict) > len(maxdict): maxdict = adict print('i:', i, ' max:', len(maxdict), ' time:', time() - t) print(maxdict) break else: adict[tmp] = 1 if i == 14316: print(i) return min(maxdict.keys())
from script import maths Max = 28123 abund = [x for x in range(10, Max) if sum(maths.all_factors(x)) > x + x] abundict = dict.fromkeys(abund, 1) def Euler_23(): tot = 0 for i in range(1, Max): sums = 1 for j in abund: if j > i: break if abundict.get(i - j): sums = 0 break if sums: tot += i return tot if __name__ == "__main__": print(Euler_23())
from script import maths Max = 28123 abund = [x for x in range(10, Max) if sum(maths.all_factors(x)) > x + x] abundict = dict.fromkeys(abund, 1) def Euler_23(): tot = 0 for i in range(1, Max): sums = 1 for j in abund: if j > i: break if abundict.get(i - j): sums = 0 break if sums: tot += i return tot if __name__ == '__main__': print(Euler_23())