3 ms·
It's obvious if you look at the version with 11 first. I find the alternating digit sum method is easier to use for 11. They're competely equivalent, but your
by dmurray 6y ago
It's obvious if you look at the version with 11 first.
I find the alternating digit sum method is easier to use for 11. They're competely equivalent, but your method makes it seem like you need to remember more state. For example, to test 678101 for divisiblity by 11 you'd go "678101, 67809, 6771, 676, 61, nope". With the alternating digits method you go "1, 1, 2, -6, 1, -5, nope" only dealing with one-digit numbers at every step. Maybe with practice you learn to ignore the leading digits until you need them.
- eps 6y agoFor 11 the even faster method is to just do this: 678101 -> 6-7+8-1+0-1 = 5 -> no bueno 874632 -> 8-7+4-6+3-2 = 0 -> divides by 11 The exact same idea, but even less "state" needed as you put it.
- dmurray 6y agoThink you're doing the exact same as me but I started from the right. 1-0+1-7+8-6. This way you end up with the remainder mod 11, if you start from the left you sometimes need to flip the sign at the end.