Hacker News new | ask | show | jobs
by macintux 3086 days ago
Another useful trick the other direction, which I'm sure is mentioned somewhere in the article or the comments but what the heck: if the sum of the digits of a number is divisible by 3, so is the original number itself.

123: 1 + 2 + 3 = 6, 6 rem 3 == 0, so 123 is cleanly divisible by 3.

123456789: sum is 45, 4+5 is 9, 9 rem 3 == 0, so 123456789 is divisible by 3.