3 ms·
Analogous rules can be made for every divisor, but at any rate, here's how it works: 10 is 1/2 in mod 19 world (that is, 10 * 2 = 1 in mod 19 world). So if you
by Chinjut 6y ago
Analogous rules can be made for every divisor, but at any rate, here's how it works:
10 is 1/2 in mod 19 world (that is, 10 * 2 = 1 in mod 19 world). So if you have a number ABCD, which means A * 10^3 + B * 10^2 + C * 10 + D, that turns into A / 2^3 + B / 2^2 + C / 2 + D in mod 19 world.
If that's zero, your original number was divisible by 19, otherwise it wasn't. More generally, this would have the same remainder modulo 19 as the original number.
Just as well, instead of looking at ABCD, we can divide it through by 10^3 and look at A.BCD = A + B / 10 + C / 10^2 + D / 10^3. This amounts to starting with D, dividing by 10 and adding C, then dividing by 10 again and adding B, etc.
In mod 19 world, A.BCD = A + B * 2 + C * 2^2 + D * 2^3, and amounts to starting with D, then doubling it and adding C, then doubling that and so on. Again, if the result is zero, the original number was divisible by 19, otherwise it wasn't.
In general, this "Go from least significant digit to most significant digit, constantly doubling and adding the next digit" process will yield as its result 2^(number of digits - 1) * the original number, in mod 19 world.