(All numbers in this post are dozenal, not decimal, unless otherwise noted.)
The trick for a prime divisor $p$ (that is not a factor of the base) is to find the smallest multiple of the base (in this case, a dozen), positive or negative, that is equal to one modulo $p$. Then you multiply the ones place by this positive or negative factor and add the positive or negative result to the number represented by the remaining digits of the original number. If the result is a number known to be a multiple of the divisor $p$ (including zero), the original number is also a multiple of $p$; if the result has an absolute value in the open interval $(0, p)$ or is a number known to not be a multiple of $p$, the original number is not a multiple of $p$; if neither of those conditions are met, repeat the process on the result.
For division by five, the smallest positive multiple that satisfies this condition is three dozen, while the smallest negative multiple that satisfies this condition is negative two dozen; since two is smaller than three, we use negative two as our multiplier, giving the test for five mentioned in the question. For division by seven, the smallest positive multiple that satisfies this condition is three dozen, while the smallest negative multiple that satisfies this condition is negative four dozen; since three is smaller than four, we use positive three as our multiplier, giving the test for seven mentioned in the question.
For division by one-dozen-and-five (15), the smallest positive multiple that satisfies this condition is ten dozen, while the smallest negative multiple that satisfies this condition is negative seven dozen; since seven is smaller than ten, we use negative seven as our multiple, giving the following algorithm:
- Subtract seven times the ones place from the number represented by the remaining places.
- Repeat until you reach an absolute value of 15 or below.
- If the result is 0 or 15, the original number is divisible by 15.
- Example: $22B$
- $22B → 22 − (7 × B) = 22 − 65 = −43$
- $43 → 4 − (7 × 3) = 4 − 19 = −15$
- Thus, $2B$ is divisible by 15.
- Example: $794$
- $794 → 79 − (7 × 4) = 79 − 24 = 55$
- $55 → 5 − (7 × 5) = 5 − 2B = −26$
- $26 → 2 − (7 × 6) = 2 − 36 = −34$
- $34 → 3 − (7 × 4) = 3 − 24 = −21$
- $21 → 2 − (7 × 1) = 2 − 7 = −5$
- Thus, $794$ is not divisible by 15.
This same trick works for other prime divisors, though there are special cases for numbers one below and one above the base that may be simpler. In dozenal, an alternate test for division by eleven ($B$) is to add up all the digits of a number; if the result is divisible by eleven, so is the original number. An alternate test for one-dozen-and-one (decimal thirteen) is to alternately add and subtract each digit (e.g. add the ones place, subtract the dozens place, add the grosses place, subtract the great-grosses place, et cetera); if the result is divisible by one-dozen-and-one, so is the original number.
since $\bmod 17!:,\ \color{#c00}{\dfrac{1}{12}}\equiv \dfrac{1}{-5}\equiv\dfrac{3}{-15}\equiv \dfrac{20}2\equiv 10\equiv \color{#c00}{-7},$ by Gauss's algorithm
– Bill Dubuque Apr 19 '22 at 15:22