E129: Euler lucky constants for \(n^2 + n + b\)

Preview figure for E129
Preview figure for E129

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

Highlights

  • Compares several classical “lucky” constants \(b\) side-by-side.

  • Heatmap shows prime/composite patterns across \(n\) for each \(b\).

  • Report includes the first failure \(n\) and a factorization witness.

Goal

Compare how long \(n^2+n+b\) stays prime at the start for a small set of classical constants \(b\). We quantify the initial prime streak length and visualize where it breaks.

Background (quick refresher)

Research question

Among a short list of traditional “Euler lucky numbers” \(b\), which yields the longest initial prime streak for \(f(n)=n^2+n+b\) and how do the failures look (first composite and its factors)?

Method

  • Choose a list of constants \(b\).

  • For each \(b\), evaluate \(f(n)\) for \(n=0..N\).

  • Use a sieve to classify values as prime/composite and measure the initial run length.

  • Visualize a prime indicator map and a bar chart of run lengths.

How to run

make run EXP=e129

or:

uv run python -m mathxlab.experiments.e129

Outputs

This experiment follows the standard output contract:

  • out/e129/figures/ — generated figures (PNG)

  • out/e129/report.md — short narrative report

  • out/e129/params.json — run parameters (stable JSON)

  • out/e129/logs/ — run logs (created by the runner/Makefile)

Published run snapshot

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

Reproduce:

make run EXP=e129

Parameters

  • n_max: 200

  • b_values: [2, 3, 5, 11, 17, 41]

Summary

b

initial prime run

first non-prime n

f(n)

factorization

2

1

1

4

2^2

3

2

2

9

3^2

5

4

4

25

5^2

11

10

10

121

11^2

17

16

16

289

17^2

41

40

40

1681

41^2

Notes

  • Many quadratics look prime-rich on small ranges; a short streak does not imply a deep theorem.

  • For any fixed b, there are always modular obstructions (e.g. the b-multiple subsequence for n=bk when b is prime).

Outputs

  • figures/fig_01_prime_indicator_heatmap.png

  • figures/fig_02_initial_run_lengths.png

  • params.json

  • report.md

params.json (snapshot)
{
  "b_values": [
    2,
    3,
    5,
    11,
    17,
    41
  ],
  "max_listed": 10,
  "n_max": 200,
  "seed": 1
}

References

  • Lucky numbers and Euler’s polynomial: contributors [2025], Weisstein [2025].