#!/usr/bin/env python3 """job #1382 -- the single-killer column K*({p}) as a function of p, every reachable level. Instrument: period_check.c UNCHANGED (full period = the phase-max object), one run per (level, p). For each level x the column is the whole list p -> K*({p}) for primes p > x up to a fixed bound, and the report per column is: the value sequence, the number of RECOVERIES (a strict decrease followed later by a strict increase), the last p with K* > 1, and the p at which the final 1-plateau starts. """ import pathlib import subprocess BASE = pathlib.Path(__file__).resolve().parent BIN = BASE / "period_check" BOUND = {5: 41, 7: 43, 11: 47, 13: 53, 17: 79, 19: 127, 23: 127} def is_prime(n): if n < 2: return False d = 2 while d * d <= n: if n % d == 0: return False d += 1 return True def kstar(level, p): r = subprocess.run([str(BIN), str(level), str(p)], capture_output=True, text=True) if r.returncode != 0: return None for line in r.stdout.splitlines(): if "K*(Q)=" in line: return int(line.split("K*(Q)=")[1].split()[0]) return None summary = [] for level in sorted(BOUND): primes = [q for q in range(level + 2, BOUND[level] + 1) if is_prime(q)] vals = [(p, kstar(level, p)) for p in primes] print(f"T{level} ({len(vals)} primes, p = {primes[0]}..{primes[-1]})") print(" " + " ".join(f"{p}:{v}" for p, v in vals)) seq = [v for _, v in vals] recov = 0 for i in range(1, len(seq)): if seq[i] < seq[i - 1] and any(w > seq[i] for w in seq[i + 1:]): recov += 1 last_gt1 = None for p, v in vals: if v > 1: last_gt1 = p # start of the final 1-plateau plateau = None for i in range(len(seq) - 1, -1, -1): if seq[i] != 1: plateau = vals[i + 1][0] if i + 1 < len(vals) else None break print(f" recoveries (dip then later rise): {recov} last p with K*>1: {last_gt1}" f" final 1-plateau starts at: {plateau} max {max(seq)} min {min(seq)}") print() summary.append((level, len(vals), recov, last_gt1, plateau, max(seq), seq)) print("=" * 70) print("SUMMARY") print(f"{'level':>5} {'#primes':>7} {'recoveries':>10} {'last K*>1':>9} {'plateau':>7} {'max':>4}") for level, n, recov, last_gt1, plateau, mx, _ in summary: print(f"{level:>5} {n:>7} {recov:>10} {str(last_gt1):>9} {str(plateau):>7} {mx:>4}") nonmono = [s for s in summary if s[2] > 0] print(f"columns with at least one recovery: {len(nonmono)} of {len(summary)}") print("column values are the phase-max K*({p}) (period_check.c, full period)")