E002: Even Perfect Numbers — Generator and Growth

Preview figure for E002
Preview figure for E002
Preview figure for E002

Tags: number-theory, quantitative-exploration, visualization, numerics See: Valid Tags.

Highlights

  • Generate even perfect numbers from known Mersenne exponents \(p\).

  • Plot digits and bit-length growth vs. \(p\).

  • Test the approximation \(\log_{10}(N(p)) \approx 2p\log_{10}(2)\).

Goal

Generate even perfect numbers from known Mersenne prime exponents \(p\) and visualize how fast the numbers grow. Measure growth via digit count, bit length, and simple logarithmic approximations.

Research question

For

\[ N(p) = 2^{p-1}(2^p-1), \]
how do:

  • \(\mathrm{digits}(N)\),

  • \(\mathrm{bit\_length}(N)\),

  • \(\log_{10}(N)\)

scale with the exponent \(p\)?

How accurate is the approximation

\[ \log_{10}(N(p)) \approx 2p\log_{10}(2)? \]

Why this qualifies as a mathematical experiment

The Euclid–Euler theorem tells us exactly what even perfect numbers look like, but it does not directly convey how quickly the objects become astronomically large. This experiment uses computation and visualization to build quantitative intuition and test simple asymptotic approximations.

Experiment design

Inputs

  • A curated list of known Mersenne prime exponents, e.g. \(p \in \{2,3,5,7,13,17,19,31,\dots\}\).

Observables

For each exponent \(p\):

  • \(N(p)\) as a Python integer

  • \(\mathrm{digits}(N(p))\)

  • \(\mathrm{bit\_length}(N(p))\)

  • approximation error:

    \[ \Delta(p) = \log_{10}(N(p)) - 2p\log_{10}(2) \]

Plots

  • \(p\) vs. digits

  • \(p\) vs. bit length

  • \(p\) vs. \(\Delta(p)\)

How to run

From the repo root:

make run EXP=e002

or:

uv run python -m mathxlab.experiments.e002

Notes / pitfalls

  • Avoid converting huge integers to decimal strings repeatedly in tight loops; compute digits using logs where possible.

  • Use int.bit_length() for stable bit length (fast and exact).

  • Keep the exponent list modest for fast docs builds; this is a growth experiment, not a search for new Mersenne primes.

Extensions

  • Compare growth to \(2^{2p}\) and quantify the relative gap.

  • Add a “human scale” axis: compare \(\mathrm{digits}(N(p))\) to common benchmarks (atoms in the observable universe, etc.).

  • Pull the exponent list from a small data file so the experiment can be updated without code changes.

Published run snapshot

If this experiment is included in the docs gallery, include the published snapshot (report + params).

Reproduce:

make run EXP=e002 ARGS="--seed 1"

Seed: 1

Exponents

Mersenne prime exponents used in this run:

2, 3, 5, 7, 13, 17, 19, 31

Outputs

  • figures/fig_01_digits_vs_p.png

  • figures/fig_02_bits_vs_p.png

  • figures/fig_03_log10_error_vs_p.png

  • params.json

Notes

  • Growth is extreme: both digits and bit length scale roughly linearly in p.

  • The log-approximation error stays bounded and illustrates why N(p) behaves like 2^(2p) up to a small correction.

params.json (snapshot)
{
  "exponents": [
    2,
    3,
    5,
    7,
    13,
    17,
    19,
    31
  ]
}

References

See References.

[Caldwell, n.d., Voight, 1998, OEIS Foundation Inc., 2025]