Test if a number is divisible by 3
Submitted by Isoscel on Sat, 11/17/2007 - 16:42.
How to test if a number is divisible by 3?
You just add its digits and test if the result is divisible by 3.
Examples:
24 is divisible by 3 because 2+4=6 is divisible by 3.
84 is divisible by 3 because 8+4=12 is divisible by 3.
123 is divisible by 3 because 1+2+3=6 is divisible by 3.
Why is this so?
Because the difference between a number and its sum of digits is a multiple of 3:
For example:
- (a + b + c + d) = a 1000 + b 100 + c 10 + d - (a + b + c + d) =
= 999 a + 99 b + 9 c = 3(333 a + 33 b + 3 c)