Re:Testing for Divisibility by 19
by mcv on Monday November 23, 2020 @06:18AM
(#25185597)
I wonder if it doubles the residue. 20 -> 2, 21 -> 4. But 18 -> 17. And 10 -> 1. So no.
[ Parent
| on HN ]
It does double the residue, but modulo 19. 2 * 18 = 36 = 17 (mod 19) and 2 * 10 = 20 = 1 (mod 19). The reason is that the method consists essentially of two steps. (1) Subtract a suitable multiple of 19 to make the number a multiple of 10. (2) Divide by 10. And dividing by 10 is the same as multiplying by 2, since 2 * 10 = 20 = 1 (mod 19).
Re:Testing for Divisibility by 19
by MauranKilom on Monday November 23, 2020 @06:49AM
(#25185737)
Well, it does double the residue:
20 * 2 === 40 === 2 (mod 19)
21 * 2 === 42 === 4 (mod 19)
18 * 2 === 36 === 17 (mod 19), equivalently -1 * 2 === -2 === 17 (mod 19)
10 * 2 === 20 === 1 (mod 19), equivalently -9 * 2 === -18 === 1 (mod 19)