Proof of the above method:

Consider each digit seperately. The digit in the '1's place (d0) is just exactly what it is. The digit in the '10's place (d1) has the value (10 * d1) = ((3 * 3 * d1) + d1) = ((3 * N1) + d1) for N1 equal to some integer (specifically, (3 * d1)). Now, A is divisible by 3 if and only if (A - (3 * N1)) is divisible by 3. So the number ((10 * d1) + d0) is divisible by 3 iff (((10 * d1) + d0) - (3 * N1)) is divisible by 3, i.e. iff (d0 + d1) is divisible by 3. The same operation can be performed for all the remaining digits, (100 * d2) = ((3 * 33 * d2) + d2), N2 = (33 * d2), and in general ((10 ^ i) * di) = ((3 * 3 * f(i) * di) + di), Ni = (3 * f(i) * di) where f(i) is the value represented by i '1' digits in a row in decimal notation.

This shows that not only can you find whether a number is divisible by 3, but exactly what number it is modulo 3 - if you end up with 0, 3, 6, or 9 then the original number is 0 modulo 3, if you end up with 1, 4, or 7 then the original number is 1 modulo 3, and if you end up with 2, 5, or 8 the original number is 2 modulo 3.

The same argument can be used to check if a number is divisible by 9, or to check what value a number is modulo 9 (use (9 * d1), N1 = d1, and (9 * 11 * d2), N2 = (11 * d2), (9 * f(i) * di), Ni = (f(i) * di)).