# Density of primes among the first $k$ numbers formed by the digits of $\pi$?

Consider the digits numbers formed by the first $$k$$ digits in the decimal representation of $$\pi, k \ge 1$$

$$3\\31\\ 314 \\3141 \\31415\\314159 \\ 3141592 \\31415926 \\314159265 \\ ...$$

Out of the first $$10^4$$ such numbers $$4000$$ (approximately $$40\%$$) end in $$1,3,7$$ or $$9$$. Since all primes $$> 5$$ end in one of these four digits I checked how many of these $$4000$$ numbers were primes and I could find only corresponding to $$k = 2,6,38$$ which is much lower than what I anticipated.

Question: In general, assuming $$0 < \alpha < 1$$ to be a normal in base $$10$$, what is the expected density of primes among the first $$k$$ numbers formed by the digits of $$\alpha$$ as explained above?

• If we assume random digits, we can estimate the number of primes with the $1/ln(n)$-approach. – Peter Jan 16 '20 at 13:54
• I think, a high search limit has already been established. Maybe, you look it up at OEIS. – Peter Jan 16 '20 at 13:56
• digits in order ? there's a thread on mersenne forum by david eddy you might like. – user645636 Jan 16 '20 at 18:48
• oh and the digits prior to a 1 or 7 will never form a number that is 2 mod 3. all digits prior to 3 or 9 will never form a multiple of 3. – user645636 Jan 16 '20 at 19:08
• you forgot 31 but got 13... – user645636 Jan 17 '20 at 15:48

## 1 Answer

The Prime Number Theorem states, essentially, that the number of primes less than $$N$$ is approximately $$\frac{N}{\ln{N}}$$. That means (roughly) that the probability of $$N$$ itself being prime is about $$\frac{1}{\ln{N}}$$. Remember, though, that $$N$$ is the number itself, not the number of digits it has. Since $$\ln{N}$$ is roughly equal to the number of digits of $$N$$ multiplied by $$\ln{10}$$, and since a number's index in your sequence is just the number of digits it has, that suggests that the probability that the $$k$$th number is prime should be about $$\frac{1}{k\ln{10}}$$. Assuming that whether each number is prime is independent of the primality of the ones before it, the expected number of primes should be

$$\frac{1}{\ln{10}}\left(1 + \frac12 + \frac13 + \frac14 + \cdots + \frac1k\right)$$

By a result of Euler and Mascheroni, this happens to be almost exactly $$\frac{\ln{k}}{\ln{10}} = \log_{10}k$$. $$\log_{10}{10000} = 4$$, which is exactly what your data indicates!

This is a very cool question - I've never had a density estimate work out this perfectly!