Can Mickey Mouse divide by $7$?
Solution 1:
Such graphs exist for any (non-zero) integer. In fact, the arrows reflect two basic operations $\bmod 7$:
- The black arrows represent adding one (note that they go up from $0$ to $6$ and then cyclically back to $0$ again)
- Similarly, the white arrows represent multiplication by $10$; note that $5$ goes to $1$, and this reflects the fact that $5\times10=50\equiv 1\pmod 7$.
Any given number can be written as a combination of these two operations on a starting value of zero; for instance, your example $N=325$ is equivalent to starting with zero, adding $1$ three times (giving $3$), multiplying by $10$ (giving $30$), adding $1$ twice more (giving $32$), multiplying by $10$ again (giving $320$), and then adding $1$ five more times (giving $325$). The graph just represents these operations $\bmod 7$, and so if you end up at node zero it means that your original number was a multiple of 7; this works because both the operations of adding one and multiplying by ten 'commute' through the mod-7 operation (i.e., $(n+1)\bmod 7$ $\equiv (n\bmod 7)+1\pmod 7$ and $(n\times10)\bmod 7$ $\equiv (n\bmod 7)\times 10\pmod 7$ ). Since the individual operations commute with the mod operation, so will any combination of them.
But there's nothing special about $7$ here, and in fact that's enough to understand how to construct the graph for any base $b$: number a set of $b$ nodes from $0$ to $b-1$, and then construct a black arrow from $i$ to $i+1\pmod b$ for every node $i$, and a white arrow from $j$ to $j\times10\pmod b$ for every node $j$. This will give the analogue of the 'Mickey Mouse' graph for that base.