4 ms·
A more formal treatment can be found in "Elementary Number Theory and its Applications", Kenneth H. Rosen, 3rd Ed, specifically Chapter 4, "Applications of Cong
by phs 6y ago
A more formal treatment can be found in "Elementary Number Theory and its Applications", Kenneth H. Rosen, 3rd Ed, specifically Chapter 4, "Applications of Congruences".
The 7 * 11 * 13 = 1001 development in particular appears just after example 4.4 and is then generalized to arbitrary bases by theorem 4.3. For example to divide by five in octal, do the alternating sum trick on digits grouped in pairs, because 5 divides 8^2+1.
Though it quickly stops being useful for manual checks, Fermat's Little Theorem is a fun gizmo. It says for any prime `p` (say, 17) and base `a` not divisible by it (10), we have that `a^(p-1) % p == 1`. Put another way, so long as we meet the criteria (prime, doesn't divide base), we can form a divisibility test by summing blocks of `p-1` (16) digits and testing the result, just like the `3` case.
Further, since `p-1` is even we can take the square root of both sides (`a^((p-1)/2) % p == +/-1`) and use either the sum or alternating sum tricks with blocks half that size, depending on the sign of the final `1`.