I accidentally found out that in $2^{{10}^{6}}$ (==$2^{1000000}$), there are exactly 10% digits of 6 (in the decimal form). And I would like to know - are there powers of 2 in which all the digits from 0 to 9 appear exactly 10% of the time? And if not, what is the highest number (from 1 to 10) c (for count), which c digits appear exactly 10% of the time in the decimal form of a specific power of 2 ($2^{n}$)?

c must be at least 5:

  • $2^{31}$ == $2147483648$ (10 digits; 5 digits appear once)
  • $2^{166}$ == $93536104789177786765035829293842113257979682750464$ (50 digits; 5 digits appear 5 times)

I made a small program in Python to calculate c. But I'm interested in the powers up to infinity.

for n in range(1, 10 ** 6 + 1):
    a = 2 ** n
    b = list(str(a))
    s = []
    for d in range(10):
        s.append(sum([1 if i == str(d) else 0 for i in b]))
    c = sum([1 if (j * 10 == len(b)) else 0 for j in s])
    if (c >= 5):
        print(c, n, len(b), s)

Addition: Someone noted to me that if a number contains exactly 10% digits of each digit from 0 to 9, then its sum is divisible by 9, so the number is also divisible by 9 and can't be a power of 2. But I checked also powers of 3, and also there I can't find numbers where there are more than 5 digits who appear exactly 10%. I did find solutions for 5 digits though (c==5), being $3^{20}$ and $3^{124}$, and of course also c==4 (4 powers, largest of them $3^{292}$). This while checking at least the first 200,000 powers of 3.

My hypothesis is that for powers of 2 and 3 c is 5, and c would change for other bases (and of course if the numbers are represented in another base, not base 10), but at least for base 10 I think c is never 10 for any power of a positive integer. At least not for big powers. If c is 10 then it would appear in the power of 1 ($1234567890^{1}; 11223344556677889900^{1}$) or at least powers up to 1000.


1 Answer 1


Here's a very rough heuristic argument (this is too long for a comment).

Let's assume that the digits of a power of $2$ are roughly "random" -- that is, if the number has $\ell$ digits, each of the $\ell$ digits is chosen uniformly at random from $\{0,1,\dots,9\}$. This is clearly not exactly correct, but it's a reasonable guess for at least the middle digits, which contribute most of the "arbitrariness" to the problem.

Let $b=10$, and pick some subset $S\subset\{0,\dots,b-1\}$ of digits. We'll calculate the probability that, for a number with $bk$ digits chosen randomly, for each digit $d\in S$, the number of occurrences of $d$ is exactly $k$ (i.e. $d$ occurs at exactly $1/b$ of the digits). Each of the $b^{bk}$ $bk$-digit numbers (including with leading $0$s) are equally likely to be chosen, so we need to count the number of such numbers with exactly $k$ occurrences of each $d\in S$ and divide that by $b^{bk}$.

Say $|S|=c$, and let $S=\{d_1,\dots,d_c\}$. There are $\binom{bk}k$ ways to choose the $k$ locations of $d_1$, then $\binom{bk-k}k$ ways to choose the locations of $d_2$, et cetera. So, the number of total choices for the digits in $S$ is $$\binom{bk}k\binom{bk-k}k\cdots \binom{bk-(c-1)k}k=\frac{(bk)!}{k!^c(bk-ck)!}.$$ There are $(b-c)^{(b-c)k}$ ways to choose the remaining digits, since they must all be in $\{0,1,\dots,b-1\}\setminus S$, with no other restriction. So, the desired probability is $$p_{b,c}(k):=\frac{\frac{(bk)!}{k!^c((b-c)k)!}(b-c)^{(b-c)k}}{b^{bk}}.$$

We'll now investigate, given fixed $b$ and $c$, how this quantity grows with $k$. For this, we'll use Stirling's approximation for factorials. This approximation only works with large inputs, so we'll deal with the case of $c=b$ (where we want all of the digits to occur exactly $k$ times) separately.

For $c<b$, Stirling's approximation gives the rather ugly computation \begin{align*} p_{b,c}(k) &\sim \frac{(b-c)^{(b-c)k}}{b^{bk}}\frac{\sqrt{2\pi bk}\left(\frac{bk}e\right)^{bk}}{\left(\sqrt{2\pi k}\left(\frac ke\right)^k\right)^c\sqrt{2\pi(b-c)k}\left(\frac{(b-c)k}{e}\right)^{(b-c)k}}\\ &=\sqrt{\frac{b}{(b-c)(2\pi k)^c}}, \end{align*} where $\sim$ means that the ratio between the two quantities tends to $1$ as $k\to\infty$. For $c=b$, we have $p_{b,b-1}(k)=p_{b,b}(k)$ (since if $b-1$ of the digits occur exactly $k$ times, the last must as well), and so $$p_{b,b}(k)\sim \sqrt{\frac{b}{(2\pi k)^{b-1}}}.$$

This means that, for fixed $b$ and $c$, and for large $k$, the probability that $c$ of the $b$ digits occur exactly $k$ times in a perfectly random length-$bk$ number is about some constant times $k^{-c/2}$, or $k^{-(b-1)/2}$ if $c=b$.

Now we'll apply this heuristic to the particular problem. The number of powers of $2$ of a given length in base $10$ is either $3$ or $4$, and on average it's about $r:=\log_2(10)$. Fix $S\subset\{0,1,\dots,9\}$ of size $c$. For large $N$, the expected number of powers of $2$ $2^n$ with $n>N$ with $10k$ digits for some $k$, for which every $d\in S$ occurs in $2^n$ exactly $k$ times, is very roughly $$r\sum_{k\geq \log_{10}(2^N)/10}\frac{\sqrt{\frac{10}{10-c}}}{(2\pi k)^{c/2}}=\frac{r\sqrt{\frac{10}{10-c}}}{(2\pi)^{c/2}}\sum_{k\geq rN/10}k^{-c/2}.$$

For $c>2$, this sum is finite, and should tend to $0$ quickly as $N$ grows. In particular, for $N=10^6$ (assuming it has been checked that there are no solutions $2^n$ with $n\leq 10^6$), and $c=9$ (acting as proxy for $c=10$), the sum is about $3.6\times 10^{-23}$. So, it's exceedingly unlikely, assuming our heuristic is close enough to the truth, that there are any powers of $2$ with all of the digits perfectly distributed.

For $c=2$, the sum diverges, as the harmonic series does. So, we expect infinitely many powers of $2$ to be exactly $10k$ digits long for some $k$, and to have some two digits which occur exactly $k$ times.

Some numerics to support the argument that these heuristics are reasonable:

I checked powers of $2$ up through $2^{10^5}$. Of these, exactly $10^4$ have a length which is exactly a multiple of $10$. Two of these numbers satisfied the condition for $5$ digits appearing exactly $10\%$ of the time: these are $2^{31}$ and $2^{166}$, of lengths $10$ and $50$, respectively. Two more, $2^{30}$ and $2^{398}$, satisfied the condition for $4$ digits.

Only $21$ numbers satisfied the condition for $3$ digits. These are fairly common for small $k$, and then tend to thin out, with the largest being $2^{32685}$. According to the presented heuristic, the probability that there's another such power out there is about $0.31$ (taking the value for $c=3$ and multiplying by $\binom{10}3$ to account for the number of different choices of $S$). (Edit: $2^{112380}$ works as well!)

$114$ numbers satisfied the condition for $2$ digits. These begin fairly common, but remain somewhat common throughout: the five largest such numbers I found were $$2^{90553}, 2^{92646}, 2^{93311}, 2^{96101}, 2^{98360}.$$ The fact that these approach the upper bound $10^5$ on the computation, with no signs of stopping, supports the heuristic's judgment that there should be infinitely many solutions with $c=2$.

  • 1
    $\begingroup$ For $3$ digits, there's another one! The number $2^{112380}$ has $33830$ digits, and the digits $1$, $3$, and $9$ appears exactly $3383$ times each. $\endgroup$
    – VTand
    Jan 4, 2022 at 13:54
  • 1
    $\begingroup$ Although calculations are slow, it appears that there are possibly infinite powers of 2 where c==1, which means there is exactly one digit appearing exactly 10% of the time in the decimal form. $\endgroup$
    – Uri
    Jan 4, 2022 at 17:20
  • $\begingroup$ It's worth mentioning that some powers with c==1 are adjacent, for example $2^{999999}$ and $2^{1000000}$. $\endgroup$
    – Uri
    Jan 4, 2022 at 17:22
  • 1
    $\begingroup$ @Uri There should be infinitely many with $c=1$, and in fact these should be pretty common -- about $\Theta(\sqrt n)$ of the powers of $2$ up through $2^n$ should satisfy the property with $c=1$, while only about $\Theta(\log n)$ should satisfy it for $c=2$. I believe the heuristic would also give that about $\Theta(\log n)$ of the $c=1$ powers are consecutive, although it's definitely possible there's another reason the heuristic doesn't capture why these should be a bit more common. $\endgroup$ Jan 4, 2022 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .