Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is in relation to the Euler Problem $13$ from

Work out the first ten digits of the sum of the following one-hundred $50$-digit numbers.


Now, this was my thinking:

I can freely discard the last fourty digits and leave the last ten.


And then simply sum those. This would be large enough to be stored in a $64$-bit data-type and a lot easier to compute. However, my answer isn't being accepted, so I'm forced to question my logic.

However, I don't see a problem. The last fourty digits will never make a difference because they are at least a magnitude of $10$ larger than the preceding values and therefore never carry backwards into smaller areas. Is this not correct?

share|cite|improve this question
I think you're counting from the wrong end... – Scott Morrison Jul 20 '10 at 20:33
This problem is actually small enough to use a BigNum implementation, like BigInteger in .NET 4.0. – John Gietzen Jul 20 '10 at 20:33
@Morrison: What do you mean? The smallest numbers always start at the right? @Gietzen: I think I'll try that with my next approach, thanks for the idea. – IAE Jul 20 '10 at 20:37
"First" is ambiguous. Ten leftmost or ten rightmost? I believe the people at Project Euler want the former. – badp Jul 20 '10 at 21:05
They are asking for first ten digits so you need to calculate the whole answer and then show the first 10 digits as answer – Himadri Jul 22 '10 at 5:06
up vote 7 down vote accepted

If you were supposed to find the last ten digits, you could just ignore the first 40 digits of each number. However you're supposed to find the first ten digits, so that doesn't work. And you can't just ignore the last digits of each number either because those can carry over.

share|cite|improve this answer

First you are doing it in the wrong end, second, the statement in general is still not correct.

for example:


Say if you want the first 2 digits, you will get 10 if you discard the last 2 digit and do the sum. The right answer is 11

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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