Digit sum

From Wikipedia, the free encyclopedia

In mathematics, the digit sum of a given integer is the sum of all its digits, e.g. the digit sum of 12042 is calculated as 1+2+0+4+2 = 9.

The digit sum of a base 10 integer, x, repeated until a single digit is produced, can be calculated as digit_sum(x) = x mod 9. For example, digit_sum(632) would reduce 6+3+2 = 11 to 1+1 = 2. The function returns 0 when the digit sum is 9 (or 0 as in the case of digit_sum(0)). This is also called "casting out nines".

Using alternating addition and subtraction, rather than addition alone, produces residues modulo eleven. The least significant digit should be added, the 10s digit subtracted, and so on, making it more convenient to work right-to-left. Thus 12042 produces 2−4+0−2+1 = −3, or 8 modulo 11.

Digit sums (digital roots) are useful for checking arithmetic operations of addition, subtraction, multiplication and squaring. It can also be used for quotient/remainder division. There is a limitation to this method, when an answer has error/s totalling a 9 multiple (17 x 19 = 323 but if incorrectly written as 17 x 19 = 413) then using digit sums will not reveal that the answer is in error.

See also: digital root.

[edit] External links


In other languages