# Job 4294 (route 80 step check): nearest p*-only offset of the seam window. # c = P-1 = -1 mod every prime <= x. Offset j (c+j) is killed by q iff q | (j-1)(j+1). # j is "p*-only" iff p* | (j-1)(j+1) and no other prime q <= x divides (j-1)(j+1). # The copy lemma (#1827 check C) needs the seam window to contain no p*-only offset. # For each prime level 23 <= x <= 997: p* = largest prime <= x with p*+2 not prime (the step's choice); # d = least |j| > 0 that is p*-only (exhaustive search up to p*·x + 2); compare with the step's claim # (s*p* +- 1 with s > x, i.e. about p*·x) and flag levels where d < p*·x. import sys def primes_upto(n): s = bytearray([1]) * (n + 1); s[0:2] = b"\0\0" for i in range(2, int(n ** 0.5) + 1): if s[i]: s[i*i::i] = bytearray(len(s[i*i::i])) return [i for i in range(n + 1) if s[i]] PR = primes_upto(10**6); PS = set(PR) rows = [] for x in [p for p in PR if 23 <= p <= 997]: small = [q for q in PR if q <= x] ps = max(q for q in small if (q + 2) not in PS) others = [q for q in small if q != ps] def ponly(j): a, b = j - 1, j + 1 if (a % ps) and (b % ps): return False return all(a % q and b % q for q in others) lim = ps * x + 2 d = next((j for j in range(2, lim + 1, 2) if ponly(j) or ponly(-j)), None) rows.append((x, ps, d, ps * x)) bad = [r for r in rows if r[2] is not None and r[2] < r[3]] print("levels", len(rows), "levels with nearest p*-only offset below p*·x:", len(bad)) for x, ps, d, px in bad: print(f"x={x} p*={ps} d={d} p*^2-1={ps*ps-1} p*^2-2 prime={ps*ps-2 in PS} p*·x={px}")