# Find the total number of digits in the following case.

Two numbers $2^k$ and $5^p$ are expanded first then written side by side i.e. adjacent to each other. Find the total number of digits in that case if $k = p = 2004$.

My approach :

$2004\times \log 5 = 1400$
so number of digits would be $1401$.
$2004 \times log 2 + 1 = 604$
Total digits $= 2005$

• what is the expansion base here? – Aang Jun 27 '12 at 6:45
• Decimal, apparently. OP you should be more explicit with your roundings. – anon Jun 27 '12 at 6:50
• The log which I have taken here is with base 10. – Bazinga Jun 27 '12 at 6:53
• Then,I think your result is fine. – Aang Jun 27 '12 at 6:56
• More precisely $2004 \times \log 5 = 1400.7\ldots$ and $2004 \times \log 2 = 603.26\ldots$ but apart from that you are correct – Henry Jun 27 '12 at 7:15

If you are working in base 10 you have the number of digits of $x$ as $\lfloor \log_{10} x\rfloor+1$. Assume logs are to base 10 to simplify notation.

The number of digits you need is then, as you calculate:

$\lfloor \log {2^p}\rfloor+1+\lfloor \log {5^p}\rfloor+1 = \lfloor p\log {2}\rfloor+1+\lfloor p\log {5}\rfloor+1$

Aside from the fact that you might have a rounding error of 1, you can then use $p\log2+p\log5=p\log{10}=p$.

So your answer will be $p+2 \text { or } p+1$

Then note, as Henry points out, that the logs are related - the floor function always reduces the total by 1 and never by zero, because the logs are not rational, so the answer is $p+1$

• I don't think "you need to know the logs accurately enough". It will always be $p+1$ for integer $p=k$ – Henry Jun 27 '12 at 7:11
• So my approach is correct, sirs? – Bazinga Jun 27 '12 at 7:12
• @Henry You are right, of course, because the remainders of the two floor terms are not independent of one another, but sum to 1, and as you noted in your answer, the logs are not rational, so you never get a zero. I will modify accordingly. – Mark Bennet Jun 27 '12 at 7:16
• @Bazinga: Yes, your approach works (though there is some rounding) and would work for more general $k$ and $p$ – Henry Jun 27 '12 at 7:16

Your method works though for integer $k=p \gt 0$ you do not even have to calculate the logarithms.

Since $k \, \log_{10}(5) + k \,\log_{10}(2) = k \, \log_{10}(10) = k$ and the logarithms are not rational numbers, then the number of digits of the concatenated number must be $k+1$.