# Bound on number of zeros in smallest prime greater than $10^n$

I'm inspired by this comment by Eugene Wallingford on a blog post by John D. Cook. Take this Python code, using SymPy (note, I used this branch to ensure that nextprime is not too slow).

>>> from sympy import nextprime
>>> for i in range(20):
...     print nextprime(10**i)
...
2
11
101
1009
10007
100003
1000003
10000019
100000007
1000000007
10000000019
100000000003
1000000000039
10000000000037
100000000000031
1000000000000037
10000000000000061
100000000000000003
1000000000000000003
10000000000000000051


The commenter asked, "The ten zeros in 100000000003 raises another challenge. How about a prime with a particular number of zeros in it? I wonder how often the smallest prime of n digits is also the smallest prime with (n-2) zeros."

Is there a known bound on the number of zeros after the 1 that must be in the smallest prime greater than $10^n$? I know that the gaps between primes are unbounded, and that the probability that $N$ is prime is less and less as $N$ gets bigger, but the number of zeros in $10^n$ also grows with $n$, so it's quite conceivable that, e.g., there are at least $\frac{n}{2}$ zeros. On the other hand, it would be quite surprising if, for example, there were an integer $n > 1$ such that the first prime greater than $10^n$ is also greater than $10^n + 10^{n - 1}$.

EDIT: I guess one should also ask on a lower bound, that is, an upper bound on the number $p - 10^n$, where $p$ is the smallest prime greater than $10^n$.

Some of the questions can be answered using the following theorem of Pierre Dusart.

For $x\gt 400000$, there is always a prime between $x$ and $x\left(1+\frac{1}{25\log^2 x}\right)$.

That amply deals with the question about $10^n+10^{n-1}$, and much more.

For example, it guarantees that there are at least $4$ zeros at $10^{20}$. That is undoubtedly a very poor lower bound.

A much better estimate is 2.3 times the log of n, where n is the exponent. This is in accord with the theory of primes, and also matches perfectly the average for the first 2750 cases.

Divide the second column (the offset giving the first prime) by the first column (the exponent, n) and the average for all 2750 of them is 2.32095668 which is also the natural log of 10. The Theory of Prime predicts one prime per natural log of the region in question, so ln(10^n) couldn't be a more accurate and better estimate.

(sorry I did not know how to format the data into two columns so I removed it.)
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}