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

analytic-number-theorydivisibilityelementary-number-theorynumber theoryprime numbers

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?

Best 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!

Related Question