Why $9$ & $11$ are special in divisibility tests using decimal digit sums? (casting out nines & elevens)

I don't know if this is a well-known fact, but I have observed that every number, no matter how large, that is equally divided by $$9$$, will equal $$9$$ if you add all the numbers it is made from until there is $$1$$ digit.

A quick example of what I mean:

$$9*99 = 891$$

$$8+9+1 = 18$$

$$1+8 = 9$$

This works even with really long numbers like $$4376331$$

Why is that? This doesn't work with any other number. Similarly for $$11$$ and alternating digits sums.

• Here's something else to try: write a number $n$ such that the digits, read left to right, are increasing (e.g. 12345 or 13579). What is the sum of the digits of $9 \times n$? Dec 31 '10 at 20:32
• I guess the gist is "10 makes 9 special" :-) Jan 1 '11 at 0:24
• @Moron: Pretty much. Jan 1 '11 at 1:48
• I'm assuming what @Moron is referring to is Base-10, or the "Decimal Number System". Jan 1 '11 at 3:05
• 9 is dead. Because 7 8 9!! Ah ah ah ah. Feb 9 '11 at 23:07

Not quite right, since $9\times 0 = 0$ and the digits don't add up to $9$; but otherwise correct.

The reason it works is that we write numbers in base $10$, and when you divide $10$ by $9$, the remainder is $1$. Take a number, say, $184631$ (I just made it up). Remember what that really means: $$184631 = 1 + 3\times 10 + 6\times 10^2 + 4\times 10^3 + 8\times 10^4 + 1\times 10^5.$$ The remainder when you divide any power of $10$ by $9$ is again just $1$, so adding the digits gives you a number that has the same remainder when dividing by $9$ as the original number does. Keep doing it until you get down to a single digit and you get the remainder of the original number when you divide by $9$, except that you get $9$ instead of $0$ if the number is a nonzero multiple of $9$.

But since every multiple of $9$ is a multiple of $9$, you will always get $9$.

Note that you have a similar phenomenon with $3$ (a divisor of $9$), since adding the digits of a multiple of $3$ will always result in one of the one-digit multiples of $3$: $3$, $6$, or $9$.

If we wrote in base $8$, instead of base $10$, then $7$ would have the property: if you write a number in base $8$ and add the digits (in base 8) until you get down to a single digit between $1$ and $7$, then the multiples of $7$ will always end yielding $7$, for precisely the same reason. And if we wrote in base $16$, then $15$ (or rather, F) would have the property. In general, if you write in base $b$, then $b-1$ has the property.

This is a special case of casting out nines, which in turn is a special case of modular arithmetic. It is what is behind many divisibility tests (e.g., for $2$, $3$, $5$, $9$, and $11$).

Coda. This reminds me of an anecdote a professor of mine used to relate: a student once came to him telling him he had discovered a very easy way to test divisibility of any number $N$ by any number $b$: write $N$ in base $b$, and see if the last digit is $0$. I guess, equivalently, you could write $N$ in base $b+1$, and add the digits to see if you get $b$ at the end.

• Yes. and another test is to write the number in base $b-1$ and check if the alternating sum adds up to zero. (mimicking the divisibility test for 11 in decimal system)
– user17762
Dec 31 '10 at 20:10

It is a special case of casting out nines, which is obvious when viewed via modular arithmetic:

$$\rm\quad mod\,\ 9\!:\, \ \color{#c00}{10\equiv 1}\ \Rightarrow\ P(\color{#c00}{10})\equiv P(\color{#c00}1)\ \,$$ for all $$\rm\color{#0a0}{polynomials}$$ $$\rm\,P(x)\,$$ with integer coefficients

But radix notation has $$\rm\color{#0a0}{polynomial}$$ form, e.g. $$\rm\ N = 567 = P(10)\,$$ for $$\rm\, P(x) = 5\, x^2 + 6\,x + 7.\,$$ Thus the above implies  mod $$\,9\!:\ \rm N = P(10)\equiv P(1) =$$ the sum $$\rm\,S_N$$ of the decimal digits of $$\rm\,N,\,$$ thus $$\rm \bmod 9\!:\,\ 567 \equiv 5\!+\!6\!+\!7\equiv 18\equiv 1\!+\!8\equiv 9,\,$$ so $$\,9\mid 567,\,$$ i.e. $$\,9\,$$ divides $$\,567$$.

OP is special case $$\rm\ N\equiv 0\pmod{\! 9}\$$ so by above it remains $$\equiv 0\$$ if we map $$\rm N$$ to its digit sum $$\rm\,S_N.\,$$ This map is strictly decreasing for $$\rm\:N > 9,\,$$ so iterating it eventually reaches some $$\rm\: N' \le 9.\$$ But $$\rm\ N'\equiv 0\pmod{\!9}\,$$ so $$\rm\: N' = 9\,$$ $$\rm (N'\!\neq0\,$$ by $$\rm\,N>0\,$$ has a nonzero digit so $$\rm\,S_N>0)$$.

If modular arithmetic is unfamiliar we could instead use divisibility rules or proceed as follows:

Factor Theorem $$\rm\,\Rightarrow\, X\!-\!1\mid P(X)\!-\!P(1)\$$ so $$\rm\ X = 10\ \Rightarrow\ 9\mid P(10)\!-\!P(1)\$$ i.e. $$\rm\; 9\mid N\! -\! S_N$$

The analogous result holds true for any radix $$\rm\:b,\,$$ i.e. we can cast $$\rm\:b\!-\!1$$'s in the same way, since

$$\rm\quad \bmod\, \color{}{b\!-\!1\!}:\,\ \color{#c00}{b\equiv 1}\,\Rightarrow\, N=P(\color{#c00}b) \equiv P(\color{#c00}1)= \text{sum of radix \rm\,b\, digits of }\, N$$

Hence $$\,\rm \bbox[5px,border:1px solid #c00]{\text{the divisor \,9\, is 'special' in radix \,10\, because }\, \color{#c00}{10\,\equiv\, 1}\,\pmod{\! 9}}$$

Similarly we cast $$11$$'s by $$\!\rm\bmod 11\!:\ \color{#c00}{10\equiv -1}\,\Rightarrow\, P(\color{#c00}{10})\equiv P(\color{#c00}{-1})\equiv p_0 -p_1 + p_2 -p_3 +\cdots$$

Hence $$\,\rm \bbox[5px,border:1px solid #c00]{\text{the divisor 11 is 'special' in radix \,10\, because } \color{#c00}{10\equiv -1}\pmod{\!\! 11}}$$

Similarly we may cast $$\,1001 = 7\cdot 11\cdot 13\,$$ by taking the alternating digit sum in radix $$\,10^3,\,$$ yielding a combined divisibility test for $$\,7,11,13\,$$. We get countless divisibility tests via such modular reduction, e.g. see here for casting out $$\,91$$'s.

It deserves to be better known that we may also cast out nines to check rational arithmetic - as long as the fractions have denominator coprime to $$3$$, e.g. see Hilton; Pedersen, $$1981,\,$$ Casting out nines revisited (these results are very old). Analogous remarks hold true for any ring that has $$\ \mathbb Z/9\$$ as an image - just as one can apply parity arguments in any ring that has $$\ \mathbb Z/2\$$ as an image, e.g. the ring of all rationals with odd denominator, or the ring of Gaussian integers $$\,\mathbb Z[i],\,$$ where the image $$\, \mathbb Z[i]/(2,i\!-\!1) \cong \mathbb Z/2\$$ yields the natural parity definition: $$\, a+b\:i\$$ is even $$\iff a\equiv b\pmod{\! 2},\,$$ i.e. if $$\, a+b\:i\$$ maps to $$\:0\:$$ via the above isomorphism, which maps $$\, 2\to 0,\ i\to 1\:$$. See here for further discussion of parity in rings of algebraic integers, including examples of number rings with no parity structure, and with more than one parity structure. See also this post for "casting out orders" in cyclic groups, and see this thread for an in-depth comparison of various elementary inductive proofs of casting nines.

These are elementary prototypical examples of problem-solving by way of modular reduction - one of the keystones of abstract algebra. As such one should be sure to understand these simple instances before moving on to more advanced manifestations of modular reduction.

Beware  Such casting-out rules are often advocated for use in checking arithmetic. But keep in mind that such checks won't reveal all arithmetical errors, i.e. there can be many "false positives", since the check only verifies that expressions agree modulo some small number, e.g. integers agreeing mod $$10$$ means only that they have the same final digits. To remedy this we can perform checks modulo sufficiently many coprime moduli (see CRT = Chinese Remainder Theorem). This is one example of various "lifting" techniques employed in modular computation methods - which you can read about in most textbooks on computer algebra, e.g. Knuth, TAOCP, vol. 2, Seminumerical Algorithms, or von zur Gathen: Modern Computer Algebra.

• I was going to mention 'casting out nines' if no one else did, so I up-voted this answer. Jun 25 '11 at 21:38

Many ways to say this I suppose - what made sense to me when I first was confronted with this fact is that the number "$abcd$" is $1000a+100b+10c+d=(999a+99b+9c)+a+b+c+d$. The first term is clearly divisible by $9$ so if the digit sum is then "$abcd$" is as well...

This follows from the divisibility test for $9$ and from the fact that the sum of the digits of a natural number with more than one digit is strictly less than the number itself i.e. if $n$ is a natural number with more than one digit and if $s(n)$ denotes the sum of the digits of the natural number then $s(n)<n$. Your observation can be strengthened to note that if we keep repeatedly adding the digits, the final number we are left with is the remainder when divided by $9$.

This property is based on the fact that $9$ is one minus $10$ which is the base of the number system you are working with because of this any power of $10$ will equal $1$ modulo $9$.

$9$ is also special for accounts in finding book keeper errors of transposed digits.

$124+256+345=725$

$124+265+345=734$

$734-725=9$

• Seems only for single digit errors. Request explanation why works for such errors alone. Nov 19 '21 at 9:10

The "specialness'' of $$9$$ stems from the fact that $$10 \equiv 1 \pmod{9}$$.

So, in our base-10 numeral system in which an integer can be expressed as

$$d_{k}d_{k-1} \ldots d_{1}d_{0} = d_{k}10^{k} + d_{k-1}10^{k-1} + \ldots + d_{1}10 + d_{0}$$

$$\equiv d_{k}(1) + d_{k-1}(1) + \ldots + d_{1}(1) + d_{0} \pmod{9},$$

all we need to do is to evaluate the sum $$d_{k} + d_{k-1} + \ldots + d_{1} + d_{0}$$ and check to see if it is divisible by $$9$$ in order to determine if the given integer is divisible by $$9$$.

Finally, note that a similar test with analogous justification also exists for determining if a given integer is divisible by $$3$$, as $$10 \equiv 1 \pmod{3}$$.