Proof of the above method:

Consider each digit seperately. The digit in the '1's place (`d`_{0}) is just exactly what it is. The digit in the '10's place (`d`_{1}) has the value (10 * `d`_{1}) = ((3 * 3 * `d`_{1}) + `d`_{1}) = ((3 * `N`_{1}) + `d`_{1}) for `N`_{1} equal to some integer (specifically, (3 * `d`_{1})). Now, `A` is divisible by 3 if and only if (`A` - (3 * `N`_{1})) is divisible by 3. So the number ((10 * `d`_{1}) + `d`_{0}) is divisible by 3 iff (((10 * `d`_{1}) + `d`_{0}) - (3 * `N`_{1})) is divisible by 3, i.e. iff (`d`_{0} + `d`_{1}) is divisible by 3. The same operation can be performed for all the remaining digits, (100 * `d`_{2}) = ((3 * 33 * `d`_{2}) + `d`_{2}), `N`_{2} = (33 * `d`_{2}), and in general ((10 ^ `i`) * `d`_{i}) = ((3 * 3 * `f`(`i`) * `d`_{i}) + `d`_{i}), `N`_{i} = (3 * `f`(`i`) * `d`_{i}) 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 * `d`_{1}), `N`_{1} = `d`_{1}, and (9 * 11 * `d`_{2}), `N`_{2} = (11 * `d`_{2}), (9 * `f`(`i`) * `d`_{i}), `N`_{i} = (`f`(`i`) * `d`_{i})).