# E047: Fermat numbers: Pépin test + factor witnesses ```{figure} ../_static/experiments/e047_hero.png :width: 80% :alt: Preview figure for E047 ``` ```{figure} ../_static/experiments/e047_hero_2.png :width: 80% :alt: Preview figure for E047 ``` **Tags:** `number-theory`, `counterexample-search`, `visualization`, `fermat` See: {doc}`../tags`. ## Highlights - Runs Pépin’s test for $F_n = 2^{2^n} + 1$ (definitive for Fermat numbers). - Finds small, explicit factor witnesses by bounded trial division. - Visualizes how explosively $F_n$ grows and where the first counterexample appears. ## Goal Demonstrate (computationally) why the statement “all Fermat numbers are prime” fails, and produce concrete witnesses. ## Background (quick refresher) - {doc}`../background/fermat-numbers` ## Research question How quickly do Fermat numbers become composite in practice, and how easy is it to exhibit a *witness* factor for the first failures? ## Experiment design - Compute $F_n$ for $n\le n_{max}$. - Apply Pépin’s test (for $n\ge 1$) to classify prime vs. composite. - If composite, attempt to find a small factor by trial division up to a configurable bound. - Plot $\log_{10}(F_n)$ and the smallest discovered factor (if any). ## Reproducibility - `params.json` records the run settings. - `report.md` summarizes the key findings. - `figures/*.png` contains the plots for the run. ## Interpreting the results - If Pépin says “composite”, the number is definitively composite (not a probabilistic claim). - The factor search is bounded: “no factor found” does not mean “prime”. - The classic factor for $F_5$ (and often for $F_6$) appears quickly under the default bounds. ## Published run snapshot If this experiment is included in the docs gallery, include the published snapshot (report + params). ```{include} ../reports/e047.md :start-after: "" :end-before: "" ``` ::: {dropdown} params.json (snapshot) :open: ```{literalinclude} ../params/e047.json :language: json ``` ::: ## References See {cite:t}`KrizekLucaSomer2013LecturesOnFermatNumbers`, {cite:t}`WikipediaContributors2025FermatNumber`, {cite:t}`OEISFoundationInc2025A000215FermatNumbers`. ## Related experiments - {doc}`e012` (Fermat pseudoprimes and Carmichael numbers (counterexamples)) - {doc}`e048` (Carmichael numbers: Korselt scan + Fermat counterexamples) - {doc}`e009` (Small-factor scan for Mersenne numbers) - {doc}`e015` (Wilson test infeasibility) - {doc}`e041` (Fermat numbers: not all prime)