#!/usr/bin/env python3 """Check of Proposition 2 (b) => (a) at small scale: for every twin pair (r, r+2) with r = 11 or 17 (mod 30) and 210 < r < LIMIT, let x be the smallest prime with x# > r. Verify: y(x) < r, r is in the comb N_x, r survives every scour prime x < q <= y(x). Also verify E(7) = (2/30)*prod_{7<=p<=13}(1-2/p)*210 and the ensemble cardinality condition prod_{x= W at x = 7 and 11. Single thread, stdlib, < 5 s.""" import math, sys LIMIT = int(sys.argv[1]) if len(sys.argv) > 1 else 200000 N = LIMIT + 3 s = bytearray([1]) * (N + 1); s[0] = s[1] = 0 for i in range(2, int(N**0.5) + 1): if s[i]: s[i*i::i] = bytearray(len(range(i*i, N+1, i))) P = [i for i in range(N + 1) if s[i]] def primorial_level(r): W = 1 for p in P: W *= p if W > r: return p, W def y_of(W): # largest prime with y^2 <= W y = None for p in P: if p * p <= W: y = p else: break return y checked = fails = 0 for r in range(211, LIMIT): if s[r] and s[r+2] and r % 30 in (11, 17): x, W = primorial_level(r) y = y_of(W) ok = y < r and all(r % p not in (0, p-2) for p in P if 7 <= p <= y) checked += 1; fails += (not ok) if not ok: print("FAIL", r, x, W, y) print(f"twin pairs r=11,17 mod 30 in (210,{LIMIT}): {checked}; failures of (b)=>(a): {fails}") E7 = (2/30) * (1-2/7) * (1-2/11) * (1-2/13) * 210 print(f"E(7) = {E7:.4f} (note: 6.92)") for x in (7, 11): W = math.prod(p for p in P if p <= x); y = y_of(W) prod = math.prod(q for q in P if x < q <= y) print(f"x={x} W={W} y={y} scour primes={[q for q in P if x=W: {prod>=W}")