A few weeks ago I heard someone casually refer to ‘that formula of Euler’s that generates primes’. I hadn’t heard of this, but it turns out that in 1772 Euler produced this formula:
Using this,
This got me wondering. Clearly
for prime
I wrote some code to investigate this. Lately, I’ve taken to writing C++ when I need a bit of code, for practice, so I wrote this in C++.
I figured the cases where
So I kept track of the primes
I put the primes that work into the OEIS and saw that I had generated a list of the smaller twin in each pair of twin primes. I was momentarily spooked by this, until I realised it was obvious. Since
What about the lengths of the sequences of consecutive primes generated? The table below shows the sequences of consecutive primes generated for small values of
Primes generated | Number of consecutive primes generated | ||
3 | 3, 5 | 2 | |
5 | 5, 7, 11, 17 | 4 | |
11 | 11, 13, 17, 23, 31, 41, 53, 67, 83, 101 | 10 | |
17 | 17, 19, 23, 29, 37, 47, 59, 73, 89, 107, 127, 149, 173, 199, 227, 257 | 16 | |
29 | 29, 31 | 2 |
I was pleased to see this sequence of lengths of primes generated was not in the OEIS. So I submitted it, and it is now, along with the code I wrote. (I discovered along the way that the version where sequences of length one are included was already in the database.)
Anyway, I amused myself by having some C++ code published, and by citing Euler in a mathematical work. Enjoy: A371896.
The appearance of 17 and 41 here is not coincidental, it’s related to deep matters of factorization, and occurs because and are the largest Heegner numbers. I asked about this on Math SE a while back and got a really excellent answer by Will Jagy.
The appearance of 17 and 41 here is not coincidental, it’s related to deep matters of factorization, and occurs because and are the largest Heegner numbers. I asked about this on Math SE a while back and got a really excellent answer by Will Jagy.