# E049: Wieferich primes (base 2): scan and quotient visualization ```{figure} ../_static/experiments/e049_hero.png :width: 80% :alt: Preview figure for E049 ``` ```{figure} ../_static/experiments/e049_hero_2.png :width: 80% :alt: Preview figure for E049 ``` **Tags:** `number-theory`, `counterexample-search`, `visualization`, `wieferich` See: {doc}`../tags`. ## Highlights - Scans primes up to a bound for the Wieferich condition $2^{p-1}\equiv 1\ (\mathrm{mod}\ p^2)$. - Recovers the known small hits (1093 and 3511) under default settings. - Visualizes a quotient-like value that is exactly zero for Wieferich primes. ## Goal Explore a rare strengthening of Fermat’s congruence and visualize how exceptional Wieferich primes are. ## Background (quick refresher) - {doc}`../background/wieferich-primes` - {doc}`../background/prime-numbers` ## Research question Up to a bound $B$, which primes satisfy the Wieferich condition (base 2), and how does the quotient-like statistic vary across primes? ## Experiment design - Generate all primes $p\le B$ (excluding $p=2$ for base 2). - Compute $r = 2^{p-1} \bmod p^2$ and derive $q = (r-1)/p\ (\mathrm{mod}\ p)$. - Mark primes with $q=0$ as Wieferich hits. - Plot hit positions and a scatter of $q$ values. ## Reproducibility - `params.json` records the run settings. - `report.md` summarizes the key findings. - `figures/*.png` contains the plots for the run. ## Interpreting the results - Hits at 1093 and 3511 confirm the implementation. - The quotient scatter is purely exploratory; it’s a compact way to see “how far” a prime is from the Wieferich condition. - Increasing the bound quickly becomes compute-heavy (but remains feasible for moderate bounds in pure Python). ## Published run snapshot If this experiment is included in the docs gallery, include the published snapshot (report + params). ```{include} ../reports/e049.md :start-after: "" :end-before: "" ``` ::: {dropdown} params.json (snapshot) :open: ```{literalinclude} ../params/e049.json :language: json ``` ::: ## References See {cite:t}`Wieferich1909ZumLetztenFermatschenTheorem`, {cite:t}`OEISFoundationInc2025A001220WieferichPrimes`, {cite:t}`WikipediaContributors2025WieferichPrime`. ## Related experiments - {doc}`e018` (Miller–Rabin base choice counterexamples) - {doc}`e048` (Carmichael numbers: Korselt scan + Fermat counterexamples) - {doc}`e008` (Lucas–Lehmer scan (prime exponents)) - {doc}`e009` (Small-factor scan for Mersenne numbers) - {doc}`e042` (Repunit primes (small k scan))