Sub topic 10
Digit Sums and Remainders Modulo 9 and 3
Assume you know whole-number arithmetic, basic divisibility tests, and remainders. This chapter develops a fast method for finding remainders when dividing by 9 or 3.
The place-value reason
A decimal number such as \(7384\) can be written using place values:
\[ 7384=7(10^3)+3(10^2)+8(10)+4. \]
Modulo \(9\) means comparing remainders after division by \(9\). Since
\[ 10\equiv 1\pmod 9, \]
every power of \(10\) also leaves remainder \(1\):
\[ 10^2\equiv 1,\qquad 10^3\equiv 1\pmod 9. \]
Therefore,
\[ 7384\equiv 7+3+8+4\pmod 9. \]
The number and its digit sum always have the same remainder modulo \(9\). The same result works modulo \(3\), because \(10\equiv1\pmod3\).
The digit-sum rule
To find the remainder of a decimal number modulo \(9\) or \(3\):
- Add its digits.
- If needed, add the digits of the result again.
- Use the final value to determine the remainder.
For \(7384\),
\[ 7+3+8+4=22. \]
Because \(22\div9\) leaves remainder \(4\),
\[ 7384\equiv4\pmod9. \]
Because \(22\div3\) leaves remainder \(1\),
\[ 7384\equiv1\pmod3. \]
The repeated process is called reducing to a digital root. For example,
\[ 58,239\rightarrow5+8+2+3+9=27\rightarrow2+7=9. \]
Thus \(58,239\) is divisible by \(9\), and therefore also divisible by \(3\).
| Digit sum result | Remainder modulo 9 | Divisible by 3? | Divisible by 9? |
|---|---|---|---|
| 0, 9, 18, 27, ... | 0 | Yes | Yes |
| 1, 10, 19, ... | 1 | No | No |
| 2, 11, 20, ... | 2 | No | No |
| 3, 12, 21, ... | 3 | Yes | No |
A number is divisible by \(3\) exactly when its digit sum is divisible by \(3\). It is divisible by \(9\) exactly when its digit sum is divisible by \(9\).
n = 7384
digit_sum = sum(int(d) for d in str(n))
print(digit_sum) # 22
print(n % 9) # 4
print(digit_sum % 9) # 4
print(n % 3) # 1
print(digit_sum % 3) # 1Using unknown digits
Suppose \(47x2\) is divisible by \(3\), where \(x\) is one digit. Its digit sum is
\[ 4+7+x+2=13+x. \]
This must be a multiple of \(3\). Since \(13\) leaves remainder \(1\), \(x\) must leave remainder \(2\) modulo \(3\). The possible digits are
\[ x\in\{2,5,8\}. \]
If the number must be divisible by \(9\), then \(13+x\) must be a multiple of \(9\). The only possible digit is \(x=5\), because \(13+5=18\).
Common errors
- Do not confuse the digit sum with the original number. They have the same remainder modulo \(3\) or \(9\), but they are usually different numbers.
- A number divisible by \(9\) is always divisible by \(3\), but the reverse is not always true. For example, \(12\) is divisible by \(3\), not by \(9\).
- Do not discard zeros incorrectly. Zeros add nothing, but they still occupy a place in the original number.
- The rule applies to decimal notation. In another base, the relevant digit-sum modulus changes.
Exercise
Find the digit \(x\) if \(62x4\) is divisible by both 3 and 9.
Show answer
The digit sum is \(6+2+x+4=12+x\). For divisibility by 9, \(12+x\) must be a multiple of 9. Thus \(x=6\), and the number is 6264.