Here is a more elaborate description of the problem statement. What I found with a few examples is that given a number, say 569. If we are required to sum its digits repetitively until the sum is single digit, i.e

1)5+6+9 = 20;
2)2+0 = 2
where 2 is single digit sum

We can compute the result, 2, with just one run through the number as follows:

1) 5+6 = 11 // adding first 2 digits of 569
2) 1+1 = 2 // adding the sum of 5,6 since its more than 1 digit
3) 2 + 9 = 11 // adding the sum of digits of 11 to 9, the last digit of 569
4) 1 + 1 = 2 // summing the digits of result of step 3
which yields the same result, 2.

Could someone prove mathematically(or otherwise) why this works? OR provide an example where it won't work? I'm pretty sure it works all the time but don't have a proof..

Edit 1: @Mark Bennet. Thanks for your answer. I was able to fill in the gaps and understand why the answer can be derived directly from the initial positive number using modulo 9. I will write out the proof after telling what I didn't understand.

Let original number be n. I understood that the answer would be x = n%9 if x > 0 and 9 if x = 0;

However, what I didn't understand is, why when going by the less efficient way of repetitively summing the digits of the numbers, the order of adding the digits does not matter.

Proof of what I got from your explanation:

Let n be original number, s1, s2, s3, ..., sk be the sums formed by adding the digits. Let sk be single digit. We know what n-s1, s1-s2, s2-s3 are all divisible by 9 because of your explanation. So we can add them all up, cancelling s1,s2, ..., sk-1j, until we are left with just n-sk which is also divisible by 9.

So, we can write n = 9p+sk where p >=0. By definition, sk is n%9.

What I didn't understand, (or rather connect this proof to) what my question is initially seeking an answer for: If I still went by my way of adding digits repetitively, why does the order of adding digits not matter?

  • $\begingroup$ So you're asking if, and in that case why, one can calculate the digit sum in any order? $\endgroup$ – Arthur Dec 9 '18 at 8:25
  • $\begingroup$ I tried doing that as well and it seemed to work. You can try it too $\endgroup$ – user3760100 Dec 9 '18 at 14:33

Think about just one digit. In the original number it appears as $a\times10^r$ because of its "place value". In the sum of digits it appears just as $a$.

The difference between the two is $a\times (10^r-1)$, and you will see that $10^r-1$ has every digit $9$ (or is zero if $r=0$) and is therefore divisible by $9$.

The difference between the original number and its sum of digits is therefore divisible by $9$, and this can be used to show that when you start with a positive integer the single digit you get at the end is $9$ if the number is divisible by $9$ or is otherwise the remainder you get when you divide the original number by $9$.

It doesn't matter how this sum is calculated - beginning with a single digit shows that this can be done digit by digit. The difference at every stage between the number you started with and the one you finish with is divisible by $9$. That is the key point.

I have left some gaps for you to fill in. There are plenty of slick proofs out there ("casting out nines" is an old name for this, which was a check on arithmetic in the days before electronic calculators), but you will do best to work it through for yourself.

  • $\begingroup$ can you please help me out with the part I still didn't get. I've edited my answer to describe what I understood $\endgroup$ – user3760100 Dec 9 '18 at 15:20
  • $\begingroup$ @user3760100 I think that the root is that addition is commutative (so the order of addition for integers doesn't matter) and the reduction from integers to integers modulo $9$ - so that numbers which differ by a multiple of $9$ count as the same - is a homomorphism of rings, so respects the original addition, and therefore is also unaffected by any changes in the order of doing things. You've probably got the associative property in there as well. In other words it is down to very basic properties of integers which we tend to take for granted and only notice when they surprise us. $\endgroup$ – Mark Bennet Dec 9 '18 at 18:26

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.