E047: Fermat numbers: Pépin test + factor witnesses

Preview figure for E047
Preview figure for E047

Tags: number-theory, counterexample-search, visualization, fermat See: Valid 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)

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).

Parameters

  • n_max: 6

  • factor_prime_bound: 1000000

Results (bounded)

n

F_n

Pépin says prime?

smallest factor found

0

3

1

5

2

17

3

257

4

65537

5

4294967297

641

6

18446744073709551617

274177

Notes

  • Pépin’s test is definitive for Fermat numbers (n ≥ 1).

  • The factor search here is bounded trial division, meant to produce small, explicit witnesses (e.g., for F_5 and F_6).

params.json (snapshot)
{
  "factor_prime_bound": 1000000,
  "n_max": 6
}

References

See Kř\'ıžek et al. [2013], Wikipedia contributors [2025], The OEIS Foundation Inc. [2025].