This article is from the Puzzles FAQ, by Chris Cole email@example.com and Matthew Daly firstname.lastname@example.org with numerous contributions by others.
What is the test to see if a number is divisible by nine?
If the sum of the digits is divisible by nine, so is the number.
Every integer n can be expressed as
n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
Note that 10 is congruent to 1 (mod 9). Thus 10^k is congruent to 1 (mod 9) for
every k >= 0.
Thus n is congruent to (a1+a2+a3+....+a_k+1) mod(9).
Hence (a1+a2+...+a_k+1) is divisible by 9 iff n is divisible by 9.