Re:Divisibility by 7 is a Walk on a Graph (2009)
by Jtsummers on Monday November 09, 2015 @10:20AM
(#10533460)
Using the same approach I used to construct the formulation, divisibility by 2 and 5 actually just break down to the normal "is the last digit even" or "is the last digit 5 or 0" tests. We end up with:
10*A + B = 0 (mod 2)
B = 0 (mod 2)
and:
10*A + B = 0 (mod 5)
B = 0 (mod 5)
Of course, these are trivially small cases and we've all learned the patterns. An interesting case with N = 4, the quick method I learned in grade school was to look at the last two digits. But using the approach I've adopted here, you get something more complex:
10*A + B = 0 (mod 4)
2*A + B = 0 or 2*A - 3*B = 0 (mod 4)
If we instead break N into ABC (A * 100 + B * 10 + C = N):
EDIT: Formatting.