# Are 0 and 1, respectively, the least and most used digits among primes?

In order to write the first 25 primes (2 to 97), 46 digits are necessary, nine of each of the digits 2, 3, and 7, fewer of all the others. Thereafter, at least for a while, the digit 1 is used more times than anyother digit, while the digit 0 fewer times than any other.

Does this phenomenon persist forever thereafter?

This question arose during discussions at the 2023 Soacha, Colombia Math Circle.

A related question is here: https://puzzling.stackexchange.com/questions/122129/number-of-1s-needed-to-write-all-primes-up-to-p

• This holds for primes up to $10^4.$ Aug 16, 2023 at 20:15
• Your title asked the opposite question from your body, so I edited it to match. I hope that was correct. Aug 16, 2023 at 20:22
• Maybe this imbalance just comes from Benford's law, combined with the fact that the last digits of primes >5 can only be 1,3,7.9? If so, the imbalance should become less prominent as the numbers increase: even if there are regularities in the first and last digit, eventually they are just a negligible percentage of all the digits. Aug 16, 2023 at 20:37
• The asymptotic distribution of all digits within primes is the same - this follows from normality of the Erdos-Copeland constant (this argument is of course kind of backwards, but this is convenient to point to references). This still leaves the question of statements analogous to Chebyshev bias but I wouldn't have any idea how one would prove that. Aug 16, 2023 at 20:43
• While Benfords law gives bias in the first $O(1)$ digits and divisibility criteria give bias in the last $O(1)$, the Cramer model suggests random fluctuations in most of the last $O(\log\log n)$ digits. So the bias should disappear asymptotically, though this may be challenging to discern numerically. Aug 17, 2023 at 5:50

I guess it's OK to reply to a question about an empirical observation with more empirical observations.

Here's a Mathematica histogram of the digits of the first million primes:

Now I make a "fakePrime" function that instead of giving the $$n$$th prime gives a random number ending in 1, 3, 7, or 9 of size around $$n\log{n}$$:

Pretty close.

As partly mentioned in the comments, this is probably just a combination of general properties of sets of numbers with a density similar to the primes and the fact that primes end in 1, 3, 7 or 9.

• The millionth prime is $p=15,485,863$, so the primes between $10,000,000$ and $p$ are contributing a lot of ones. I'd be more impressed by a study of primes up to $9,999,999$. There might still be a slight bias in favor of $1$, since there are more primes between $1,000,000$ and $1,999,999$ than between, say, $9,000,000$ and $9,999,999$, but I don't think this counts as an instance of Benford. Aug 16, 2023 at 23:51
• @GerryMyerson Agreed. Mentioning Benford's law was a bit of a red herring but I do expect to see more 1s at the start for the reason you mention. Aug 17, 2023 at 1:16
• How about making charts like this where you do not count the first and last digits? Aug 18, 2023 at 1:10
• There's already work like arxiv.org/abs/1603.03720 Aug 18, 2023 at 22:54