Write n = a_k*10^k + a_k-1*10^(k-1) + ... + a_0. Then use the homomorphism phi from Z to Z/3Z:
phi(n) = phi(a_k*10^k + a_k-1*10^(k-1) + ... + a_0) = phi(10^k)*phi(a_k) + phi(10^(k-1))*phi(a_k-1) + ... + phi(a_0) = phi(a_k) + phi(a_k-1) + ... + phi(a_0) = phi(a_k + a_k-1 + ... + a_0) since 10 = 1 mod 3
So, n mod 3 = a_k + a_k-1 + ... + a_0. This means that 3 divides n only if 3 divides the sum of the digits of n.