4 ms·
Divisibility by any n is a walk on a graph with n nodes, each one representing one of the modulus equivalence classes 0 .. n-1.
by recursive 15y ago
Divisibility by any n is a walk on a graph with n nodes, each one representing one of the modulus equivalence classes 0 .. n-1.
- jowiar 15y agoAnd there are graphs going either way, either starting from most or least significant digit. (Take previous modulus, *10 mod N, + next digit mod N), or (Take previous modulus, + 10^(next digit) mod N)