Hacker News new | ask | show | jobs
by schoen 3964 days ago
The "other bases" issue, which you come to right at the end, fascinated me in middle school: for the reasons you describe, digital root tests for divisibility by a digit d work in any base b if d divides (b-1). For example, in hexadecimal there is a digital root test for divisibility by 1 (trivially), 3, 5, or 15 in hexadecimal.

For instance, D+E+A+D+B+E+E+F=104₁₀ which is not divisible by 5, but that indicates that (DEADBEEF+1) will be divisible by 5, which is correct.

We're also used to the "final digit test" for divisibility in base 10, which works for 1 (trivially), 2, 5, and 10; and indeed it works for a digit d in a base b if d divides b. Ternary has a digital-root test to determine whether a number is even (as in all odd bases, you can't use the final digit alone to answer that question). For example, 1202112₃ is odd because 1+2+0+2+1+1+2 is odd.

(Edit: deleted a spurious claim about hexadecimal divisibility tests.)