2
$\begingroup$

There is a debate about this Project Euler problem in the discussion thread for the problem.

The debate is whether you only have to add the first 12 digits of each number in order to get the answer.

For the particular question, it works fine if you only sum the first 12 digits of each number. But is this always the case?

$\endgroup$
  • $\begingroup$ I'm not sure that suffices to solve the problem. The $11$th digit may depend on the $12$th digit. $\endgroup$ – Daniel Mar 27 '15 at 3:22
  • $\begingroup$ Thanks. I edited my post to say the first 12 digits. $\endgroup$ – ktm5124 Mar 27 '15 at 3:29
  • $\begingroup$ But again, the $12$th digit depends on the $13$th digit! $\endgroup$ – Daniel Mar 27 '15 at 3:30
  • $\begingroup$ Haha, touche. So the carry from the last 38 digits could affect the outcome of the first 10? In fact... the carry from the last N digits could affect the outcome of the first 10, for any N >= 1? $\endgroup$ – ktm5124 Mar 27 '15 at 3:30
  • $\begingroup$ Ross Millikan's comment talks about it: Every digit affect the previous one. $\endgroup$ – Daniel Mar 27 '15 at 3:32
1
$\begingroup$

It does not necessarily work. Consider the following fifteen $12$-digit numbers:

\begin{align} 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ 100000000019&\,\\ \underline{+ \,\,\,100000000019}&\,\\ 1500000000\color{red}{2}85&\,\\ \end{align}

But

\begin{align} 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ 10000000001&\,\\ \underline{+ \,\,\,10000000001}&\,\\ 1500000000\color{red}{1}5&\,\\ \end{align}

Also, are you sure the result is the same if you ignore the $12^\text{th}$ digits? There are $100$ numbers in the $12^\text{th}$ places, and there is a high chance that their sum affects the $10^\text{th}$ place (it suffices that their average is at least $1$, but as Ross Millikan points out, it is also possible for the $12^\text{th}$ place digits to carry over without a total of $100$).

$\endgroup$
  • $\begingroup$ But your example only has 15 numbers. Is it significant that there are 100 in the Project Euler problem? (As multiplying any number by 100 shifts its digits two places over.) $\endgroup$ – ktm5124 Mar 27 '15 at 3:27
  • $\begingroup$ Your last paragraph is wrong. One can construct an example where the carry goes forward as far as you want. The probability that it does (given "random" numbers to sum) goes down by a factor of $10$ for each extra digit that you keep, but it is still possible. $\endgroup$ – Ross Millikan Mar 27 '15 at 3:29
  • $\begingroup$ @RossMillikan You're right, I'll fix it. EDIT: should be better now? $\endgroup$ – Zubin Mukerjee Mar 27 '15 at 3:30

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.