I already understand the divisibility rule for 12. $$10\equiv -2 \pmod{12} \implies 10^n\equiv (-2)^n \pmod{12}$$
Then for some number $n = abcd = 1000a + 100b + 10c + d, abcd\equiv1000a + 100b + 10c + d \pmod{12}$
Then $abcd\equiv (-2)^3a + (-2)^2b + (-2)c + d$
Example: $7368\equiv -8*7 + 4*3 -2*6 + 8\equiv -48\equiv 0 \pmod{12}$
But why does it work for 21 as well?
If I switch the order that the power rises in, so that now it is $a + (-2)b + (-2)^2c + (-2)^3d$ now, all of a sudden, it works for mod 21
Example: $2331\equiv 2 + (-2)*3 + (-2)^2*3 + (-2)^3*1 \equiv 0 \pmod{21}$
It's obvious why this works for numbers like $48$ and $84$ since with both you are multiplying $4 * -2$ and $8 * 1$ and their sum is then $0$ for both.
But why does it still work for numbers like $105$.
$501$ is obviously not divisible by $12$ and yet: $105\equiv 1 + (-2)*0 + (-2)^2*5\equiv 21 \equiv 0 \pmod{21}$
I'm also fairly sure this is part of the reason that $f$ works in Proof of general divisibility rule