This procedure is sometimes called "casting out nines", because nines can be discarded as you go. They're always divisible by 9 anyways.
This works because we are using a base ten number system. If you usually write your numbers in octal, i.e. base 8, you can tell very quickly whether a number is divisible by 7. Add up the octal digits and see if the result is divisible by 7.
Since 3 goes into 9, you can add up the digits to determine whether a large number is divisible by 3. Since 2 and 5 divide into 10, you only need consult the last digit to see if a number is divisible by 2 or 5, or 10. Examine the last two digits to see if a number is divisible by 4, 20, 25, 50, or 100.