1

In Project Euler problem 16, you have to sum up the digits of $2^{1000}$. A non-brute force solution had the prerequisite to know the length of the result beforehand and the following formula gave the result: $1000\log_{10}(2)+1$. Could someone explain where this came from? And add a generalization (and resources on the background of the topic).

JRN
  • 6,566
zeller
  • 111
  • Can you clarify the question? Are you asking how to arrive at the given formula for the number of digits in a large power of $2$? – Sammy Black Oct 03 '13 at 09:51
  • 2
    In general, every integer $n$ is between $10^{r-1}$ and $10^r$ for some $r$, and such an integer has $r$ digits (can you see why?). And the base-10 log of $n$ is between $r-1$ and $r$. So, the number of digits is one more than the integer part of the base-10 log. Now: generalize this to base $b$ for arbitrary (integer) $b$ (greater than 1). – Gerry Myerson Oct 03 '13 at 09:52
  • @SammyBlack: more generally, how to predict the number of digits in the result of an operation. Gerry Myerson: I'll try to understand about your explanation. – zeller Oct 03 '13 at 10:06
  • @GerryMyerson I understand now, thanks. Though I can only empirically prove your first "lemma"... – zeller Oct 03 '13 at 10:18
  • Worth having a look at http://math.stackexchange.com/questions/410738/digits-in-a-large-power-of-two and http://math.stackexchange.com/questions/426138/is-there-an-algorithm-to-find-the-number-of-digits-in-2n-where-n-is-a-positive and http://math.stackexchange.com/questions/335055/what-is-the-relationship-between-base-and-number-of-digits and http://math.stackexchange.com/questions/459564/find-the-number-of-digits-of-20132013 – Gerry Myerson Oct 03 '13 at 12:08

0 Answers0