TITLE: Number of digits until a prime is reached
QUESTION [14 upvotes]: Begin with a random digit from $1$ to $9$. Add a random digit to the right-hand side from $0$ to $9$ until a prime number is reached. How many digits are necessary in the avarage ?
More precisely: Let $X$ be the number of digits until a prime is reached. Does $E(X)$ exist, and if so, is there a suitable estimate?

REPLY [3 votes]: Let's assume some hard conjectures, which state that the primes behave like a random set of integers with density $\frac{1}{\log x}$, after removing "local conspiracies" (i.e., all sufficiently large primes are coprime to any fixed integer).
Let $a_n$ be the choice after the first $n$ digits. Then $10^{n}<a_{n+1}<10^{n+1}$. We estimate that a given integer (coprime to $10$) of this magnitude is prime with probability $\frac{1}{n\log 10}$. Thus an arbitrary integer is prime with probability $$p_n=\frac{\phi(10)}{10n\log 10}=\frac{2}{5n\log 10}=\frac{\alpha}{n}$$
So now the question is: I flip a coin with probability $p_n$ of turning up heads at turn $n$. What is the expected number of flips before I get a heads?
This in turn is given by
$$E=\alpha\sum_{n=1}^{\infty}\left[\prod_{i=1}^{n-1}\left(1-\frac{\alpha}{i}\right)\right]\sim \alpha\sum_{n=1}^{\infty}\left[\prod_{i=1}^{n-1}\exp\left(-\frac{\alpha}{i}\right)\right]\sim\alpha\sum_{n=1}^{\infty}e^{ -\alpha\log n}=\alpha\zeta(\alpha)$$
where $\zeta$ is the Reimann zeta function.
But since $\alpha < 1$, this seems to suggest that the expection diverges; there is no finite point at which you would expect to have found a prime.