6

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,5$. Then $$N=2\times 3\times 5+1=31$$ which is a prime.

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

But, this lead me to a different question. In both the mentioned cases, as is in general, if we start with the first $k$ primes, the "new prime" is the list will not be the $(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=\{p_1,p_2,\dots ,p_k\}$ be a finite set of primes. Apply the following algorithm-

  1. Define $N=\prod_{i=1}^kp_i+1$
  2. If $N$ is prime, add $N$ to the set $P$, i.e., take $P=P\cup \{N\}$.
  3. If $N$ is not prime, let $N=q_1^{\alpha_1}q_2^{\alpha_2}\dots q_m^{\alpha_m}$ where $q_i<q_{i+1}\forall i\in\{1,2,\dots ,m-1\}$. Add $q_1$ to $P$, i.e., take $P=P\cup \{q_1\}$
  4. Repeat steps 1,2,3 using updated $P$.

Euclid's proof guarantees that this algorithm will never stop. The question is, for what initial "seeds" $P$ is this algorithm guaranteed to hit some given prime $p$ 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 seeder $P$, 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\cup \{q_1,q_2,\dots q_m\}$" (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.

This link pointed out by Steven Clark and this one by Gerry Myerson may be of some help.

This question is now also in MathOverflow.

Sayan Dutta
  • 10,345
  • 2
    This question seems related to https://oeis.org/A051342 "Smallest prime factor of 1 + (product of first n primes)." which gives a few references but I'm not sure if any of them provide any insight. – Steven Clark Dec 11 '21 at 21:07
  • 2
    What do you do when hitting a non square-free number? – reuns Dec 11 '21 at 21:29
  • 1
    pick a computer language, start with primes 2,3,5, see how many steps are needed to reach prime 37. – Will Jagy Dec 11 '21 at 22:41
  • @reuns you take the least prime among the "new primes" you found and add that to the list irrespective of the type of number you're dealing with. – Sayan Dutta Dec 12 '21 at 10:06
  • There is some discussion of this at https://math.dartmouth.edu/~carlp/nothingtalk2.pdf – Gerry Myerson Dec 12 '21 at 12:10
  • 1
    In your question you said that you found two primes in $7\cdot 19$ not just one, so it seems you are confused. @WillJagy says that if instead you add all the prime powers factors to the list then you can look at the sequence $a_{n+1} = a_n(a_n+1)\bmod q$ and find that $a_0=30,q=37$ won't hit $0\bmod q$. If you don't do this, adding the least or the largest or all the prime factors then it will be impossible to say anything, extracting the prime factors won't let us look at the reduction $\bmod q$, so it will be only conjectural: yes obviously it will hit every prime but nobody can prove it. – reuns Dec 12 '21 at 17:06
  • 2
    @WillJagy When extracting the least prime factor you can surely conjecture that the "probability" that $q$ divides $\prod_{j\le n} p_j + 1$ is roughly $\frac1{q-1}$ so $q$ will get inserted in the list with a probability $1$. – reuns Dec 12 '21 at 18:25
  • 3
    https://oeis.org/A000945 is the Euclid-Mullin sequence: $a_1=2$, $a_{n+1}$ is smallest prime factor of $1 + \prod_{k=1\dots n}a_k$. Whether this sequence contains every prime is an open question. Many references and links are given. – Gerry Myerson Dec 13 '21 at 03:44
  • @reuns I just meant to say what influenced this question. You can either add the least new prime or all the new primes. I don't think it will matter any more that being "quicker" in getting new primes. Also, you said quite a lot in the comments- I think, you shoukd poat all these as an answer. – Sayan Dutta Dec 13 '21 at 07:11
  • 1
    @GerryMyerson This is an useful link. Thanks! – Sayan Dutta Dec 13 '21 at 07:11
  • 1
    Minor point: You don't need the "$\setminus P$" part of "${\operatorname{min}\left({q_1,q_2,\dots q_m}\setminus P\right)}$"; the "$+1$" in the definition of $N$ guarantees its prime factors don't belong to $P$. – Barry Cipra Dec 13 '21 at 18:11
  • @BarryCipra Yes! Thanks for pointing it out! There was also the problem of writing $\operatorname{min}$ for no reason (since I already wrote $q_i<q_{i+1}$). I edited them. – Sayan Dutta Dec 14 '21 at 06:07
  • Now posted to MathOverflow, https://mathoverflow.net/questions/413396/a-prime-generating-algorithm – Gerry Myerson Jan 08 '22 at 15:51

1 Answers1

0

Got a few more steps by alternately using pari factoring and my small factos command; I'll put in the product $n$ and the unfactored $1+n,$ which has roughly 115 digits.

  n = 30;
 n *= 31;
 n *= 7;
 n *= 17;
n *= 11;
 n *= 751;
 n *= 23;
 n *= 29;
 n *= 109;
 n *= 193;
 n *= 1597; cout << n << mp_Factored(n) << endl;
 n *= 13;
 n *=  961861631;
 n *=  53323;
 n *=  79;
 n *=  78941;
 n *=  641;
 n *=  5689;  cout << endl<< n << mp_Factored(n) << endl;
 n *=   15997129;
 n *=   1531;
 n *=   19;
 n *=   13859; 
 n *=  mpz_class( "16592183099");
 n *=   36343;
 n *=   mpz_class( "150409865693");
 n *=  127;
 n *= 1327;
  n *= 77801;
  n *= 59;
  n *= 10837;
  system("date");
n   = 2 3 5 7 11 13 17 19 23 29 31 59 79 109 127 193 641 751 1327 1531 1597 5689 10837 13859 36343 53323 77801 78941  cdot mbox{BIG}

n= 1523335511241041137495811049364474481231883294665122812069204639470659080175224843733883488923439548981870

1+ n= 1523335511241041137495811049364474481231883294665122812069204639470659080175224843733883488923439548981871

Will Jagy
  • 146,052
  • Any particular reason you are starting with $P={2,3,5}$ as your initial "seed" set? The classic Euclid-Mullin sequence just starts with ${2}$, which takes it to ${2,3}$ and then to ${2,3,7}$; it doesn't pick up $5$ until the sixth step. – Barry Cipra Dec 14 '21 at 20:16
  • Oh, never mind. I see you're following the OP's lead. I'll leave my comment up anyway, just to point out that different seed sets give different sequences. – Barry Cipra Dec 14 '21 at 20:19
  • @BarryCipra thank you. I don't believe I noticed Euclid-Mullin before...I see, OEIS in a comment by Gerry. They had trouble at step 43. I was going to look further into available software, but I guess the message is that the thing gets difficult regardless of the initial seed. – Will Jagy Dec 14 '21 at 21:10
  • @BarryCipra the text file for that oeis https://oeis.org/A000945/b000945.txt , quite large primes before too long. I give up. – Will Jagy Dec 14 '21 at 21:50
  • 1
    I was just playing around with a variant where you ignore $2$, start with $P={3}$, take products and add $2$ instead of $1$ (to avoid even numbers). You get $P={3,5,17,257,65537,\cdots}$. Hmmm.... – Barry Cipra Dec 15 '21 at 00:55