clearly mod is the way to go in computing terms.
however, mathematical speaking a number is divisible by 3 if the sum of its digits is also divisible by 3. eg 128954 sums to 29, which sums to 11, which sums to 2 - so not divisible by 3
a number is divisible by 9 if the sum of its digits are also divisible by 9
a number is divisible by 6 if it is divisible by 3, as above, and is even.