Base ten representation: n = dr dr-1
... d0
Then n is divisible by the listed number, if
- d0 divisible by 2
- sum of the digits divisible by 3
- d1d0 divisible by 4
- d0 divisible by 5
- divisible by 2 and by 3
- dr ...d1-
2×d0 divisible by 7
Example 4319
431 - 2×9 = 413
41 - 2×3 = 35 = 5×7
If dr ...d1- 2×d0
= m×7, then dr ...d1d0
= (10×m+3×d0)×7
Example 413 = (10×5+3×3)×7 = 59×7 and then 4319
= (10×59+3×9)×7 = 617×7
- d2d1d0
divisible by 8
- sum of the digits divisible by 9
- d0 = 0
- sum of the even digits, minus sum of the odd digits,
divisible by 11
- divisible by 3 and by 4
- dr ...d1-
9×d0 divisible by 13
Example 4316
431 - 9×6 = 377
37 - 9×7 = -26 = -2×13
If dr ...d1- 9×d0
= m×13, then dr ...d1d0
= (10×m+7×d0)×13
Example 377 = (10×-2+7×7)×13 = 29×13 and then
4316 = (10×29+7×6)×13 = 332×13
- d1d0 divisible by
25
Fast
algorithm for prime factors:
- d0 + 3×d1 + 2×d2
- d3 - 3×d4 - 2×d5
... divisible by 7, where the coefficient cn
of digit dn is 10n mod 7
(taking the closest result to zero, rather than a positive result, to
help the sum cancel)
Example 4319
9 + 3×1 +2×3 - 4 = 14 = 2×7
- d0 - 3×d1 - 4×d2
- d3 + 3×d4 + 4×d5
... divisible by 13, where the coefficient cn
of digit dn is 10n mod
13
Example 4316
6 - 3×1 - 4×3 - 4 = -13
- The technique can be used for divisibility by any
prime p, where the coefficient
cn of digit dn
is 10n mod p.
- The earlier rules for 2, 3, 5 and 11 are special cases of this rule,
where the coefficients have a simple pattern.