Interesting use of remainder theorem I am asking this question in reference to this post Write an Efficient Method to Check if a Number is Multiple of 3
In the proof of the method the author writes that any 2 digit number(AB) can be written in the form $$AB=11A-A+B$$Any 3 digit number(ABC) can be written as $$ABC = 99A + A + 11B – B + C = (99A + 11B) + (A + C – B)$$ And a 4 digit number(ABCD) as $$ 1001A + D + 11C – C + 999B + B – A$$
I have tried a few test cases and it works. But how did he come up with such an observation. And how can I represent a 5 digit number in this way?
Thanks in advance 

Considering congruences modulo $11$ is easier:
\begin{align}
10^0 & \equiv 1 \pmod{11} \\
10^1 & \equiv 10 \equiv -1\\
10^2 & \equiv -1\cdot 10\equiv -1\cdot(-1)\equiv 1\\
10^3 & \equiv 1\cdot 10\equiv 1\cdot(-1)\equiv -1\\
&\dots\\
10^{2k} & \equiv -1\cdot 10\equiv -1\cdot(-1)\equiv 1\\
10^{2k+1} & \equiv 1\cdot 10\equiv 1\cdot(-1)\equiv -1
\end{align}
Thus every power of $10$ is either congruent to $1$ (for even exponents) or to $-1$ (for odd exponents). This means that when you write a number as
$$
a_0+a_1\cdot 10^1+a_2\cdot 10^2+\dots+a_n\cdot 10^n
$$
you can substitute $10^{2k}$ with $1$ and $10^{2k+1}$ with $-1$ and this will make the new number differ from the old one by a multiple of $11$. In particular, checking whether the old number is divisible by $11$ is the same as checking the new number. In the case of five digits, the number is
$$
a_0+a_1\cdot 10+a_2\cdot 10^2+a_3\cdot 10^3+a_4\cdot 10^4
$$
and the number you can consider is
$$
a_0-a_1+a_2-a_3+a_4
$$
For two digits, $a_0+a_1\cdot 10$ becomes $a_0-a_1$, and so on.
