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$

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

  • $\begingroup$ I don't think "you need to know the logs accurately enough". It will always be $p+1$ for integer $p=k$ $\endgroup$ – Henry Jun 27 '12 at 7:11
  • $\begingroup$ So my approach is correct, sirs? $\endgroup$ – Bazinga Jun 27 '12 at 7:12
  • $\begingroup$ @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. $\endgroup$ – Mark Bennet Jun 27 '12 at 7:16
  • $\begingroup$ @Bazinga: Yes, your approach works (though there is some rounding) and would work for more general $k$ and $p$ $\endgroup$ – 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$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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