same digit for two numbers A and B, proof A-B \equiv 0 \mod 9 Consider
$$A=\overline{a_0a_1\cdots a_k}$$
$$B=\overline{b_0b_1\cdots b_k}$$
$$\{a_0,a_1,\ldots ,a_k\}=\{b_0,b_1,\ldots ,b_k\}$$
How do I prove that
$$A-B\equiv 0\,\,\,\,\, (\!\!\!\!\!\!\mod{9})$$
 A: let $s(n)$ be the sum of digits of $n$. then if $n \gt 9$ we have $s(n) \lt n$. hence if we iterate $s^m(n)$ the sequence will eventually stabilize at a single digit $s^*(n)$.
LEMMA $s^*(n) \equiv_9 n$
it suffices to prove that $s(n) \equiv_9 n$. this follows from $10 \equiv_9 1$ from which, for any digit $d$, and $j \in \mathbb{N}$
$$
10^j d \equiv_9 d
$$
thus the remainder of any number modulo $9$ is the same as the remainder modulo $9$ of the sum of its digits, which means that any two numbers composed of exactly the same multiset of digits will differ by a multiple of $9$
A: $$
A = 1o^k a_0 + 10^{k-1} a_1 + ...... + 10^0 a_k
$$
$$
B = 10^k b_0 + 10^{k-1} b_1 + ...... + 10^0 b_k
$$
if for some $$1<=i,j<=k$$, $$a_1 = b_j = x$$, $$A-B$$ gives $$10^{k-i} a_i - 10^{k-j} b_j = x(10^{k-i} - 10^{k-j})$$ for some $$i$$ and $$j$$, and each digit can be paired in such way.
if $$i=j$$, then $$10^{k-i} a_i - 10^{k-j} b_j = 0$$
if $$i>j$$, then $$10^{k-i} a_i - 10^{k-j} b_j = 10^{k-i}(10^{j-i}-1)x$$
if $$j>i$$, then $$10^{k-i} a_i - 10^{k-j} b_j = 10^{k-j}(10^{i-j}-1)x$$
as $$10 ≡ 1 \pmod 9$$, $$10^m ≡ 1 \pmod 9$$, for every natural number $$m >= 1$$.
for example, if $$A = 142857$$ and $$B = 487521$$, we have $$A-B = 1*(10^5-1) + 4*(10^4-10^5) + 2*(10^3 - 10^1) + 8*(10^2 - 10^4) + 5*(10^1 - 10^2) + 7*(10^0 - 10^3) = 1*99999 +4*(-10000)*9+2*99+8*(-100)*99+5*(-10)*9+7*(-999)$$
