# Number of digits in $2^{1989}$and $5^{1989}$

I was trying to go through some basic number theory and there I saw a lot of questions based on calculating the number of digits of a number raised to some big power. Many a time the expression gets reduced to multiples of $10$ yielding many zeroes in the end but I am unable to deal with the ones where this doesn't happen.

For e.g.: All the digits of $2^{1989}$ and $5^{1989}$ are written side by side and we need to calculate the total number of digits thus obtained.

Note that if $x$ has $n$ digits, then $10^{n-1} \leq x \leq 10^n-1$. Taking the $log_{10}$ on all sides of the inequality and rounding down should yield the answer.

Well, the number of digits of a number $\text{N}\in\mathbb{N}^+$ is:

$$\mathscr{N}_{\space\text{N}}=1+\left\lfloor\log_{10}\left(\text{N}\right)\right\rfloor\tag1$$

So, when $\text{N}$ is in the form of $\alpha^\beta$:

$$\mathscr{N}_{\space\alpha^\beta}=1+\left\lfloor\log_{10}\left(\alpha^\beta\right)\right\rfloor=1+\left\lfloor\beta\cdot\log_{10}\left(\alpha\right)\right\rfloor\tag2$$

Using Hermite's identity:

$$\mathscr{N}_{\space\alpha^\beta}=1+\sum_{\text{k}=0}^{\beta-1}\left\lfloor\frac{\ln\left(\alpha\right)}{\ln\left(10\right)}+\frac{\text{k}}{\beta}\right\rfloor\tag3$$

• I found this question in an olympiad textbook and though your answer gives a very simple way to solve the problem, yet I believe that problem was meant for some other approach. Is there any other approach possible without using the logarithmic one? – Harsh Sharma Mar 1 '18 at 19:38

$\log_{10} 2 = 0.30102999566398114$ (to plenty of significant digits)

$\log_{10} 2^{1989} = 1989\cdot \log_{10} 2 = 598.748661375658$

$\implies 10^{598} < 2^{1989} < 10^{599}$, so $2^{1989}$ has $599$ digits.

Similarly $\log_{10} 5 = 0.6989700043360187$, again with sufficient precision for solution, etc.

Any other method of showing that the results are between two adjacent powers of $10$ would also work but logarithms give the direct method.

However there is also a "cheat". Note that $\log_{10} 2 + \log_{10} 5 = 1$ (since $2\times 5 =10$). Thus $1989\log_{10} 2 + 1989\log_{10} 5 = 1989$, but we know that neither $2^{1989}$ nor $5^{1989}$ will be exact powers of $10$ so the combined number of digits will be $1989+1 = 1990$. (Try it out with smaller powers!)