10=9+1; 100=99+1, 1000=999+1, and so on.
3 goes into (10^k)-1, where k is a positive integer.
n=a0+9a1+a1+99a2+a2+...
So, if we divide by 3 we can ignore (10^k)-1 because we know they are all divisible by 3.
That leaves us with a0+a1+a2+... which is simply the sum of the digits. If this sum is divisible by 3 then so is n.