#!/usr/bin/env python3 """Recompute G2(p_n#): the largest cyclic gap between consecutive twin candidates r (gcd(r(r+2), P) = 1) modulo P = p_n#, for p_n up to 19 (and 23 if memory allows), and the census prod_{2
3e8: break t = time.time() ok = np.ones(P, dtype=bool) for q in primes[:i+1]: ok[0::q] = False ok[(q-2) % q::q] = False r = np.flatnonzero(ok) census = len(r) gaps = np.diff(r) wrap = r[0] + P - r[-1] G2 = int(max(gaps.max() if len(gaps) else 0, wrap)) expected = 1 for q in primes[1:i+1]: expected *= (q-2) print(f"p_n={p:2d} P={P:>12d} census={census} (expected {expected}) G2={G2}") print(f" p_n={p:2d} elapsed {time.time()-t:.1f}s", file=sys.stderr)