Skip to content
m·amathatlas
ExploreAboutOpen problemsCited authorsMy libraryFeedback
Sign in
FRENES
Loading views…Recent views only, across all languages. Vercel history is unavailable for this page. Repeat visits in the same tab are grouped for 30 minutes.
ShareLinkedInXFacebookWhatsApp
← All open problems
Unanswered question

A prime generating algorithm

Number theory

Imported on November 28, 2026

The forum classified this question as unanswered when collected. This does not certify an open research problem; check the answers and revision history at the source.

Read the question with its definitions and background below. The source provides the full formulation and further discussion; the glossary and Wikipedia links offer additional reading aids.

Problem statement

I posted this question in MSE around a month ago, but didn't receive any suitable answers. So, I decided to give it a try here as well-

I was trying to explain the famous proof of infinitude of primes to a young one, and I tried to explicitly show some examples. So, I said something like

Let the only primes be 2,3,52,3,52,3,5. Then N=2×3×5+1=31N=2\times 3\times 5+1=31N=2×3×5+1=31 which is a prime.

So, let the only primes be 2,3,5,312,3,5,312,3,5,31. This time N=2×3×5×31+1=931=72×19N=2\times 3\times 5\times 31+1=931=7^2\times 19N=2×3×5×31+1=931=72×19 which introduces two more "new primes" in the list.

But, this led me to a different question. In both the mentioned cases, as in general, if we start with the first kkk primes, the "new prime" is the list will not be the (k+1)(k+1)(k+1)-th prime. So, my question is, if we start with a finite number of primes, and go on repeating this algorithm, are we bound to hit all the primes? If not, then what are the primes that we may hit or miss?

So, let me frame the question once again in a more mathy way

Let P={p1,p2,…,pk}P=\{p_1,p_2,\dotsc ,p_k\}P={p1​,p2​,…,pk​} be a finite set of primes. Apply the following algorithm:

  • Define N=∏i=1kpi+1N=\prod_{i=1}^kp_i+1N=∏i=1k​pi​+1.

  • If NNN is prime, add NNN to the set PPP, i.e., take P=P∪{N}P=P\cup \{N\}P=P∪{N}.

  • If NNN is not prime, let N=q1α1q2α2⋯qmαmN=q_1^{\alpha_1}q_2^{\alpha_2}\dotsm q_m^{\alpha_m}N=q1α1​​q2α2​​⋯qmαm​​ where qi<qi+1q_i<q_{i+1}qi​<qi+1​ ∀i∈{1,2,…,m−1}\forall i\in\{1,2,\dotsc ,m-1\}∀i∈{1,2,…,m−1}. Add q1q_1q1​ to PPP, i.e., take P=P∪{q1}P=P\cup \{q_1\}P=P∪{q1​}.

  • Repeat steps 1, 2, 3 using updated PPP.

Euclid's proof guarantees that this algorithm will never stop. The question is, for what initial "seeds" PPP is this algorithm guaranteed to hit some given prime ppp in a finite number of steps (if that's possible)? If it indeed does, then how many steps will it take? If not, then for some given initial seed PPP, what are the primes that we can be sure to miss? What changes (if any) will we notice if we change the 3rd step of the algorithm to "take P=P∪{q1,q2,…,qm}P=P\cup \{q_1,q_2,\dotsc, q_m\}P=P∪{q1​,q2​,…,qm​}" (i.e., instead of updating the list with the least new prime, we are updating it with all the new primes)?

Although the question apparently seems to be quite elementary, I don't see any obvious way to proceed. I just feel like we need some analytic tools to answer this. I would love to know your thoughts on it.

OEIS A051342 pointed out by Steven Clark and the talk Booker and Pomerance - Euclidean prime generators by Gerry Myerson may be of some help.

An answer by Will Jagy to the MSE question (that I linked at the beginning) gives us an idea of the algorithm using a computer programme. That may of be some help as well.

Statement and context adapted from MathOverflow · Sayan Dutta

CC BY-SA 4.0 · Formatting adapted; mathematical formulas preserved · Source history

A few useful definitions

Prime number
An integer greater than 1 whose only positive divisors are 1 and itself. Examples include 2, 3, 5 and 7.

Topics : nt.number-theory · analytic-number-theory · prime-numbers · prime-gaps

Authors listed by the source : Sayan Dutta

Sources and original status

  • MathOverflow Status in source : unanswered at collection

Last activity on the question : January 8, 2022

Coverage, sources and method

This count measures imported entries, including distinct variants. It is not a count of all open mathematical questions worldwide. One entry may belong to several fields and sources.

This directory is neither exhaustive nor updated in real time. “Reported open” describes the source classification observed at import; imported entries have not each undergone independent mathematical verification. The 32 explained entries were reviewed separately.

Formal Conjectures: only “research open” statements with no reported formal proof are retained; their tag is checked in a pinned repository revision. Variants remain distinct. A “sorry” placeholder is not sufficient to establish open status.

Erdős: solved or independent problems and entries with a Lean solution are excluded, including “open (Lean)”. Exact matches to the main Formal Conjectures statements are merged.

Open Problem Garden: the open index is checked against the solved index; spam, identified clones and some outdated statuses are excluded. Statements and definition context are attributed to their original pages; formulas are preserved and the content remains under the GFDL. Recognized duplicates across sources are merged; this does not resolve every mathematical equivalence.

OEIS: direct extraction of conjectural comments and formulas, one entry per sequence, excluding mentioned resolutions. MathOverflow and Math Stack Exchange: questions classified as unanswered by their API, excluding closed posts and non-research categories. They remain distinct from problems reported open. This is a partial, dated collection; every entry credits its authors and license.

Documented exclusions account for recent announcements and conflicting statuses. A stronger variant or a special case can remain open after a different statement is settled.

Attribution: The Formal Conjectures Authors; teorth/erdosproblems and contributors; Open Problem Garden and contributors. Each source retains its license.

  • Formal Conjectures · 1,924 · Apache-2.0 / CC-BY-4.0
  • Erdős Problems (teorth) · 622 · Apache-2.0
  • Open Problem Garden · 404 · GFDL (source content); only title/category/link metadata imported
  • OEIS · 18,857 · CC BY-SA 4.0
  • MathOverflow · 19,035 · CC BY-SA (version on each entry)
  • Mathematics Stack Exchange · 35 · CC BY-SA (version on each entry)
Report a development or correction
mathatlas

An independent atlas to understand, read, and question research.

The papers present claimed results at different stages of verification.
NewsletterShare feedbackAbout Data and privacy
Created by Sonny Mupfuni