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

  • 2
    $\begingroup$ This holds for primes up to $10^4.$ $\endgroup$
    – kodlu
    Aug 16, 2023 at 20:15
  • 1
    $\begingroup$ Your title asked the opposite question from your body, so I edited it to match. I hope that was correct. $\endgroup$
    – LSpice
    Aug 16, 2023 at 20:22
  • 5
    $\begingroup$ 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. $\endgroup$ Aug 16, 2023 at 20:37
  • 12
    $\begingroup$ 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. $\endgroup$
    – Wojowu
    Aug 16, 2023 at 20:43
  • 6
    $\begingroup$ 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. $\endgroup$
    – Terry Tao
    Aug 17, 2023 at 5:50

1 Answer 1


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: enter image description here

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}$: Histogram of the digits of the first million fake primes

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.

  • 8
    $\begingroup$ 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. $\endgroup$ Aug 16, 2023 at 23:51
  • $\begingroup$ @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. $\endgroup$
    – Dan Piponi
    Aug 17, 2023 at 1:16
  • 5
    $\begingroup$ How about making charts like this where you do not count the first and last digits? $\endgroup$ Aug 18, 2023 at 1:10
  • $\begingroup$ There's already work like arxiv.org/abs/1603.03720 $\endgroup$
    – Dan Piponi
    Aug 18, 2023 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.