Finding Primes in Pi

1.7k Views Asked by At

Consider the numbers of the form $$ a_n=\lfloor\pi\times 10^{n-1} \rfloor, $$ for $n\in\mathbb{N}$. In other words, $\{a_n\}_{n\in\mathbb{N}}$ is the sequence composed of integers built from the first $n$ digits of $\pi$, so that $$ a_1=3,\,\,\,a_2=31,\,\,\,a_3=314,\,\,\,a_4=3141,\,\,\,a_5=31415,\,\,\,... $$ My question is: for which values of $n$ is $a_n$ a prime number?

I wrote a small code to find primes for $1\leq n\leq 10^4$, and I've only found primes for $n\in\{1,2,6,38\}$, which are, respectively, \begin{align} a_1&=3\\ a_2&=31\\ a_6&=314159\\ a_{38}&=31415926535897932384626433832795028841 \end{align} I found this result rather intriguing, since I'd expect to find more primes up to numbers with $10^4$ digits. Are there any more primes in this sequence? Is there an explanation for the lack of primes between $a_{38}$ and $a_{10^4}$?

3

There are 3 best solutions below

0
On BEST ANSWER

This is not so few. If we take the probability that a number $n$ is prime to be $1/\log(n)$, we would expect $\sum \frac 1{n \log (10)}\approx \frac 1{2.3}(\log(n)+\gamma)$ of them out to $n$. If we do the sum from $2$ to $10^4$ it is $3.8$ while we have $3$ and if we do it out to $16208$ we should have $4$ and we do. The sum diverges, so we should have infinitely many, but it diverges very slowly.

3
On

See https://oeis.org/A005042

There you can find out that Martin Gardner first asked Neil Sloane this question.

The next term consists of the first 16208 digits.

A naive probabilistic argument suggests that the sequence is infinite.

1
On

Other answers are much better, but at the very least, $a_n$ ending in 0, 2, 4, 5, 6, or 8 cannot be prime. For the roughly uniformly distributed digits of $pi$, that is 60% nonprime. Have not checked, but probably divisibility rules for 3 and 11 will also kick in.

(Going further/serious means working with distribution of primes, and that is Ross Millikan's answer.)