# How many zeros in the decimal representation of $5^n$?

I'm curious about some properties of the powers of 5 $$5^2=25,\quad5^3=125,\quad 5^4=625,\quad 5^5=3125,\quad ...$$ Is it true that at least $$50$$% of the digits in the decimal representation of $$5^n$$ are non-zero? This seems pretty modest since assuming each digit will be equally likely, only about $$10$$% of the digits will be zero on average. The first zero occurs at $$5^8=390625$$ and the power with the largest percentage of zeros seems to be $$5^{45}=28421709430404007434844970703125$$ in which $$\approx 22$$% of the digits are zero. I checked up to $$5^{1000}$$.

The difficulty is the statement seems so obvious from a probabilistic perspective, yet I can't pin down any definite theorems!

Obviously the first and the last 3 digits will always be non-zero so we have at least 4 non-zero digits. But I'm hoping to prove some properties about $$5^n$$ in general which require the non-zero digits to be at least linear in $$n$$. So $$50$$% would be more than enough. Really any probability $$\epsilon>0$$ will do -- bigger the better though.

Maybe analyze $$\langle 5 \rangle^\times$$ in $$\mathbb{Z}/10^k\mathbb{Z}$$? Could probability theory produce the bound in question?

• I suspect this is too hard for today's mathematics. It's probably not even known that for all sufficiently large values of $n$ there's at least one zero in the decimal expression for $5^n$. – Gerry Myerson Jul 1 at 2:41
• This question has some information about the appearance of digits in powers. These seem like hard questions! math.stackexchange.com/questions/116026/… – Steve Kass Jul 11 at 0:24
• recursive $5^n=25+100\cdot {5^{n-2}-1\over 4}\quad n>1$ – Roddy MacPhee Aug 12 at 20:23

A good picture is worth a thousand words. It seems that the number of zeroes is growing in an almost linear fashion with a fair amount of "noise" around the meadian line. Here are the results for a number of zeroes in $$5^n$$ up to $$n=10,000$$ Not much will change if you extend the range to $$n=20,000$$: Linear fit gives the following approximation:

$$n_{zero}=0.0699383 n-0.606536$$

...which means that the number of zeroes is roughly around 7%.

Mathematica provides the following regression analysis:

$$\begin{array}{l|llll} \text{} & \text{Estimate} & \text{Standard Error} & \text{t-Statistic} & \text{P-Value} \\ \hline 1 & -0.606536 & 0.354669 & -1.71015 & 0.0872544 \\ x & 0.0699383 & 0.0000307141 & 2277.07 & 5.874\cdot 10^{-24155} \\ \end{array}$$

If you try to fit the data with a parabola you get the following approximation:

$$n_{zero}=0.0931693 + 0.0697284 n+1.0494\cdot 10^{-8}n^2$$

In the given range, the quadratic term is almost neglectable which supports the conjecture that the relation between the exponent and the number of zeroes is approximately linear.

EDIT: Fun fact: $$5^{58}$$ has not a single zero.

EDIT 2: Mathematica code to play with:

countZeros[n_] := Module[
{m, cnt, d},
m = n;
cnt = 0;
While[m > 0,
d = Mod[m, 10];
If[d == 0, cnt++];
m = Quotient[m, 10];
];
Return[cnt];
];

analyzeExponents[limit_] := Module[
{i, data, exp},
i = 0;
exp = 1;
data = {};
While[i <= limit,
i++;
exp *= 5;
AppendTo[data, {i, countZeros[exp]}];
If[Mod[i, 100] == 0, Print["Reached i=", i]];
];
Return[data];
];

ListPlot[analyzeExponents]

• (+1) Would you mind sharing the code from Mathematica? – TheSimpliFire Jul 1 at 8:10
• There will be about $n\log_{10}5=0.7n$ digits, so that would make it about ten percent of the digits. The first one and last three won't be, but that is a small effect. – Empy2 Jul 1 at 8:14
• @TheSimpliFire I have updated the answer with the code. – Oldboy Jul 1 at 9:25
• These calculations confirm our intuitions, but of course they prove nothing. – Gerry Myerson Jul 1 at 10:38
• Not only this proves nothing, but it's barely related with the OP's goal: the question is not about the mean or approximate average number of zeroes, but about bounding the worst case. That is, is $z_n$ is the number of zeroes, we want to find some $\alpha$ such that $z_n/n \le \alpha$ for all $n$. In particular we want to know if $\alpha=0.5$ works . – leonbloy Jul 1 at 12:17

Turns out one good proof direction is hopeless -- but still informative.

Suppose we could bound the number of consecutive zeros that appear in $$5^n$$. So some statement like "No more than 4 consecutive zeros occur in the decimal expansion of $$5^n$$". That would give us our result since it would follow that at $$1$$ in every $$5$$ digits -- so at least $$20$$% -- are nonzero.

This turns out not to be the case. One can find arbitrarily long sequences of zeros in $$5^n$$. In fact, it is claimed that there exist arbitrarily long sequences of zeros in $$5^{m+2^m+2}$$ for sufficiently large $$m$$. For example, $$5^{2+2^2+2}=5^8=390625$$ $$5^{5+2^5+2}=5^{39}=\ ...30078125$$ $$5^{8+2^8+2}=5^{266}=\ ...10009765625$$ $$5^{12+2^{12}+2}=5^{4110}=\ ...100006103515625$$ $$5^{15+2^{15}+2}=5^{32785}=\ ...700000762939453125$$ $$5^{18+2^{18}+2}=5^{262164}=\ ...900000095367431640625$$ One can achieve this result by analyzing the $$k$$th digit of $$5^n$$ as $$n$$ varies. For example if we let $$5^n=\sum_{k=0}^\infty a_n(k)10^k$$ where each $$a_n(k)$$ is one of $$0,...,9$$. Denote the sequence of the $$k$$th digit as $$S_k=\{a_n(k)\}_{n=0}^\infty.$$ One can show that for all $$k\ge1$$ that $$S_k$$ begins a repeated cycle of length $$2^{k-1}$$ at $$n=k+1$$. The proof I found of this was tedious so I'll neglect to include it here. The important bit is this though: the first $$\lfloor k\log_5 10\rfloor$$ digits of $$S_k$$ must be zero due to the fact that $$10^n$$ grows faster than $$5^n$$. It follows that the repeated cycle of $$S_k$$, call it $$C_k$$, contains an increasingly longer prefix of zeros. Example, $$C_2=\{1,6\}$$ $$C_3=\{0,3,5,8\}$$ $$C_5=\{0,0,3,9,7,8,1,7,5,5,8,4,2,3,6,2\}$$ $$C_7=\{0,0,0,4,4,2,0,1,...\}$$ The values $$n=m+2^m+2$$ are simply the powers for which the prefixes of these cycles all line up again.

Some interesting corollaries also emerged from the proof:

$$\bullet$$ The distribution of digits in each $$S_k$$ tends to perfect equalibrium -- so $$10$$% of each digit -- as $$k$$ grows.

$$\bullet$$ Each $$S_k$$ obeys a sort of mirror image law in which there are equally many $$0$$'s and $$5$$'s, $$1$$'s and $$6$$'s, $$2$$'s and $$7$$'s, etc.