if diff>maxdiff: #print p,b,n,x,val,diff maxval,bsv,xsv,maxdiff = val,b,x,diff else: break return maxval,bsv,xsv,maxdiff ################### st = time() MX = 1000000 SubSet = RofPrimes(2,MX) # Add 1 SubSet.append(1) print "init sum", sum(SubSet) SqMax = int(MX**.5)+1 Srch = RofPrimes(SqMax-1,MX) SqSet = sorted(RofPrimes(2,SqMax),reverse = False) pused=[] dupes = [] ctr = 0 prev = 0 for i in SqSet: ctr +=1 nval,nb,np,diff = MaxNum(i,MX,Srch)
x = RofPrimes(2, MX) y = list(x) tmp = [] tmpr = [] for y1 in x: z = log(MX) / log(y1) z1 = y1**int(z) #print y1, z1 tmp.append(z1) tmpr.append(y1) #exit() for z in tmp: x.append(z) for z in tmpr: x.remove(z) x = sorted(x) x.append(1) y = sorted(y, reverse=False) for z in y: p = 0 nprev, zprev, Oprev = 0, 0, 0 makechange = False vlog = log(MX) / log(z) vmax = z**int(vlog)
print #exit() print W=[] for a,b in enumerate(T): # print a,b W.append(b[-4:]) T=[] print print #print W #L= list(product(*W)) max = 0 x.append(1) Sum = sum(x) maxlist=[] #print tmp #tmp=list(x) for l in product(*W): #l=sorted(l,reverse = False) tmp=list(x) #if GCD(l)>1:continue #s = sum(l) #print l, s tsum = 0 for j in l: #print j if j in tmp:continue
from Functions import RofPrimes, RetFact, IsPrime, gcd from itertools import permutations, combinations pm = [421, 443, 349, 379, 241, 83] pms = permutations(pm) for xms in pms: print xms, "######" x = RofPrimes(2, 200000) x.append(1) r = list(x) x = sorted(x, reverse=True) xs = RofPrimes(2, 444) xs = sorted(xs, reverse=False) for zz in xms: x.remove(zz) for zz in xms: x.append(zz) #x = sorted(x, reverse = False) ps = [] ps2 = [] l = [] rj = [] exc = range(2, 20) for sp in xs:
maxval, bsv, xsv, maxdiff = val, b, x, diff else: break return maxval, bsv, xsv, maxdiff ################### st = time() MX = 1000000 SubSet = RofPrimes(2, MX) # Add 1 SubSet.append(1) print "init sum", sum(SubSet) SqMax = int(MX**.5) + 1 Srch = RofPrimes(SqMax - 1, MX) SqSet = sorted(RofPrimes(2, SqMax), reverse=False) pused = [] dupes = [] ctr = 0 prev = 0 for i in SqSet: ctr += 1 nval, nb, np, diff = MaxNum(i, MX, Srch)
return sum(L) def notcoprime(cp,Y): for yy in Y: if gcd(yy,cp)!=1: return yy return -1 MX=10 x= RofPrimes(2,MX) print GCD(x) print x print Sum(x) y = list(x) #x = sorted(x,reverse = False) for i in xrange(MX-1,0,-1): if i in y:continue z= notcoprime(i,x) print i,z if z > 0 and i>z: x.remove(z) else: x.append(i) print sorted(x) print Sum(x)
from Functions import RofPrimes, RetFact,IsPrime,gcd x = RofPrimes(2,200000) x.append(1) r = list(x) x = sorted(x, reverse = True) xs = RofPrimes(2,444) xs = sorted(xs,reverse=False) x.remove(421) x.remove(443) x.remove(349) x.remove(379) x.remove(241) x.remove(83) x.append(421) x.append(443) x.append(349) x.append(379) x.append(241) x.append(83) ''' x.remove(3) xs.remove(3) x.append(177147) ''' #x = sorted(x, reverse = False)
from Functions import RofPrimes, RetFact, IsPrime, gcd from itertools import permutations, combinations pm = [421, 443, 349, 379, 241, 83] pms = permutations(pm) for xms in pms: print xms, "######" x = RofPrimes(2, 200000) x.append(1) r = list(x) x = sorted(x, reverse=True) xs = RofPrimes(2, 444) xs = sorted(xs, reverse=False) for zz in xms: x.remove(zz) for zz in xms: x.append(zz) # x = sorted(x, reverse = False) ps = [] ps2 = [] l = [] rj = [] exc = range(2, 20) for sp in xs:
x= RofPrimes(2,MX) y=list(x) tmp=[] tmpr=[] for y1 in x: z = log(MX)/log(y1) z1 = y1**int(z) tmp.append(z1) tmpr.append(y1) print x print tmp for z in tmp: x.append(z) for z in tmpr: x.remove(z) x = sorted(x) x.append(1) print x print Sum(x) #x2 = sorted(x,reverse = True) y = sorted(y,reverse=True) #y=[7,5,2] for z in y: #if z>=MX/2:break p = 0
print GCD(x) print x print Sum(x) y = list(x) tmp=[] for i in xrange(MX,0,-1): if IsPrime(i):continue if i in tmp:continue if notcoprime(i,x)==-1:continue #print "!",i,x s = set(RetFact(i)) isfactored = False for v in s: if v in tmp:isfactored = True;break if isfactored:continue if len(s) < 3: x.append(i) for z in s: if z in x: x.remove(z) tmp.append(z) x.append(1) print tmp print sorted(x) print Sum(x)
def Sum(L): return sum(L) def notcoprime(cp, Y): for yy in Y: if gcd(yy, cp) != 1: return yy return -1 MX = 10 x = RofPrimes(2, MX) print GCD(x) print x print Sum(x) y = list(x) #x = sorted(x,reverse = False) for i in xrange(MX - 1, 0, -1): if i in y: continue z = notcoprime(i, x) print i, z if z > 0 and i > z: x.remove(z) else: x.append(i) print sorted(x) print Sum(x)