applet-magic.com
Thayer Watkins
Silicon Valley,
Tornado Alley
& BB Island
USA

The Arithmetic of Digit Sums
for Addition, Subtraction and Multiplication

Let DigitSum(z) be the ultimate sum of digits of a decimal representation z; i.e., if the sum of digits of a decimal representation is greater than nine then the sum of the digits of that number is computed and process continued until a single digit is ultimately obtained.

This function, DigitSum( ), whose domain is decimal representations and whose range is the set of digits {0,1,2,3,4,5,6,7,8,9}. has several interesting properties; i.e.,

These propositions are to be proven below with the additional crucial proposition

This proposition is another way of saying digit sum arithmetic is simply arithmetic modulo 9; i.e., the arithmetic of remainders after division by 9. This proposition is the basis for the process known as casting out of nines which is used to provide a check on arithmetic computations. It must be noted that in DigitSum( ) computations a value of 9 is given as 9, whereas in modulo 9 arithmetic a value of 9 is given as 0; i.e., 9=0(mod 9).

In the following it is occasionally necessary to distinguish between a number and the decimal representation of that number. One can think of a number in terms of an appropriate number of tally marks so three would be (|||) and eleven (||||||||||||). Let n be a number and let Dec10(n) be the decimal representation of n.

Consider how one obtains the decimal representation of a number. To get the last digit one divides the number by ten and takes the remainder as the last digit. That last digit is subtracted from the number and the result divided by ten. Then the decimal representation of that quotient is sought. The process is repeated and the next the last digit is obtained.

An alternate characterization of the process of finding the decimal representation of a number is that the k-th power digit for a whole number n is:


ck = (trunc[n/10k])%10
 

where trunc[] means the fractional part is thrown away and m%10 means the remainder after division by 10. In terms of the terminology from the programming language Pascal the formula is


ck(n) = (n div 10k) mod 10
 

The sum of the digits for a number n is then


Sum of digits = Σk ck(n),
 

but this is not necessarily the DigitSum for the number. The process has to be repeated iteratively on the sum of the digits until a single digit result is obtained.

Proof of the Propositions

Consider two digits, a and b. If their sum is less than ten then


DigitSum(a+b) = DigitSum(a)+DigitSum(b)
and hence
DigitSum(a+b) = DigitSum(DigitSum(a)+DigitSum(b)).
 

But, if the sum of a and b is ten or more then the decimal representation of their sum is a one in the ten's place and (a+b−10) in the unit's place. Thus


DigitSum(a+b) = 1 + (a+b−10) = a+b−(10−1) = a+b−9
 

For digits the DigitSum(a)=a and DigitSum(b)=b so


DigitSum(DigitSum(a)+DigitSum(b)) = 1 + (a+b−10).
 

Therefore for any two digits a and b


DigitSum(a+b) = DigitSum(DigitSum(a)+DigitSum(b)).
 

This applies as well to the digits in the k-th place. Thus the general proposition for any two decimal representations of numbers, x and y


DigitSum(a+b) = DigitSum(DigitSum(a)+DigitSum(b)).
 

For differences, if a and b are digits and a>b then


DigitSum(a−b) = DigitSum(DigitSum(a)−DigitSum(b)).
 

On the other hand if a<b then (a−b)=−(b−a) and, since DigitSum(−c) = DigitSum(c), it also holds that


DigitSum(a−b) = DigitSum(DigitSum(a)−DigitSum(b)).
 

There is a caution for this proposition. For example, consider 34-25. The digit sums of both 34 and 25 are 7 so the digit sum of their difference is 0, whereas 34-25=9. However in digit sum arithmetic, as in modulo 9 arithmetic, 9 and 0 are equivalent. (Another way of thinking of digit sum arithmetic and modular 9 arithmentic is that they are both the arithmetic of equivalence classes. Both 0 and 9 are in the same equivalence class. In digit sum arithmetic 9 is taken as the representation of that equivalence class whereas in modular 9 arithmetic 0 is taken as the representative.

It should also be noted that a negative number −n is equivalent to 9−n. in digit sum arithmetic as well as in modulo 9 arithmetic.)

Again the above proposition in digit sum arithmetic extends to the digits in any place in a terminating decimal representation of a number.

For any terminating decimal numbers x and y then


DigitSum(x�y) = DigitSum(DigitSum(x)�DigitSum(y)).
 

Since multiplication is simply repeated addition it also follows that


DigitSum(x*y) = DigitSum(DigitSum(x)*y)
DigitSum(x*y) = DigitSum(x*DigitSum(y))
and finally
DigitSum(x*y) = DigitSum(DigitSum(x)*DigitSum(y)).
 

It was previously noted that for any two digits whose sum is greater than ten,


DigitSum(a+b) = 1 + (a+b−10) = a+b−(10−1) = a+b−9
 

In general then for any decimal representation x


DigitSum(x) = Sumofdigits(x) − m*9
where m is such that DigitSum(x) is reduced to a single digit. This definition allows the digit 9 as a possible value for DigitSum( ).
 

Another way of expressing the above is that the DigitSum for a number n is simply the remainder after division by 9; i.e., DigitSum(n)=(n%9). DigitSum arithmetic is simply arithmetic modulo 9 with 9 used to represent exact division rather than 0.

From the proposition concerning differences, DigitSum(x−y)=DigitSum(x)−DigitSum(y), it follows that


DigitSum((10−1)*n) = 0
but since 0=9
this is the same as
DigitSum(9*n) = 9.
 

(To be continued.)

For other material on digit sum arithmetic see Digit Sum Arithmetic


HOME PAGE OF applet-magic
HOME PAGE OF Thayer Watkins