# divisibility test

let $n=a_m 10^m+a_{m-1}10^{m-1}+\dots+a_2 10^2+a_1 10+a_0$, where $a_k$'s are integer and $0\le a_k\le 9$, $k=0,1,2,\dots,m$, be the decimal representation of $n$

let $S=a_0+\dots+a_m$, $T=a_0-a_1\dots+(-1)^ma_m$

then could any one tell me how and why on the basis of divisibility of $S$ and $T$ by $2,3,\dots,9$ divisibility of $n$ by $2,3,\dots,9$ depends?

I am not getting the fact why we introduce $S,T$

same question $n=a_m (100)^m+a_{m-1}(1000)^{m-1}+\dots+a_2 1000^2+a_1 1000+a_0$,

$0\le a_k\le 999$

-
The numbers $S$ and $T$ are definitely not enough to settle the question of divisibility by the various $k$ from $2$ to $9$. The number $S$ will tell us about divisibility by $3$ and $9$, while $T$ deals with $11$. – André Nicolas Jul 24 '13 at 3:59

The presence of many subscripts can make something simple look not so simple. So we deal with a number like $N=a_4\cdot 10^4+a_3\cdot 10^3 +a_2\cdot 10^2 +a_1\cdot 10^1+a_0$, where the $a_i$ are digits. Let $S=a_4+a_3+a_2+a_1+a_0$. We have $$N-S=a_4\cdot 9999+a_3\cdot 999+a_2\cdot 99+a_1\cdot 9.\tag{1}$$

The right-hand side of (1) is divisible by $3$, Thus $N-S$ is divisible by $3$. It follows that if $N$ is a multiple of $3$, then so is $S$, and that if $S$ is a multiple of $3$, then so is $N$.

It is easier to find out quickly whether $S$ is a multiple of $3$ than to find out whether $N$ is a multiple of $3$, so finding $S$ is a useful way to determine whether $N$ is a multiple of $3$.

Exactly the same holds for divisibility by $9$. The right-hand side of (1) is divisible by $9$, so $N$ is divisible by $9$ if and only if $S$ is divisible by $9$.

We illustrated the idea with a general $5$-digit number. But the same technique always works, for the same reason: $10^k-1$ is always divisible by $9$,

The numbers $S$ and $T$, by themselves, are not enough to determine divisibility by any of $2$, $4$, $5$, $6$, $7$, or $8$.

The usefulness of the number $T$ is that $N$ is divisible by $11$ if and only if $T$ is. Once you are comfortable with $S$ and $3$ and $9$, please leave a message and I can try to explain what $T$ has to do with divisibility by $11$. The idea is quite similar to the idea we have used, just a bit more messy.

-

Perhaps divisibility by $3$ is the easiest to understand, as it has the most direct application. Note that $10\equiv1\mod{3}$ so in general $10^k \mod 3 = 1$. This leads to

$$n = \sum_{k = 0}^m 10^k a_k \equiv \sum_{k = 0}^m 1 a_k = S \mod{3}$$

So $n$ and $S$ are simultaneously divisible by $3$. A similar argument will work for divisibility by $9$.

Now in cases when $10 \equiv -1 \mod{p}$, it would be useful to look at $T$ as the powers of $10$ will alternate in sign. An example of this is in developing divisibility tests modulo 11.

-
The example $p=11$ is the only case when $10\equiv -1\pmod p$. – Jonas Meyer Jul 24 '13 at 4:05

If $m=1$ then $S$ and $T$ uniquely determine the number. In any case $S$ determines the number mod $3$ and $9$, and $T$ determines the number mod $11$, as André pointed out. Unfortunately, as André also pointed out, even the combination of $S$ and $T$ does not generally determine divisibility by any of the numbers $2,4,5,6,7,$ or $8$.

Here are some examples with $m=2$:

• $336$ and $633$ have the same $S$ and $T$, but the first is divisible by $8$ (and hence by $2$ and $4$) and also by $6$ and $7$, while the other is not divisible by any of those $5$ numbers.
• $105$ and $501$ have the same $S$ and $T$, but the first is divisible by $5$ and $7$, while the other is not divisible by either of those numbers.
-