Library

DFA · Regular

Binary divisibility by 5

Reads a binary number one bit at a time and accepts exactly the multiples of 5. Each state remembers the remainder so far — five states doing long division.

r0r1r2r3r40101010101
The machine as drawn — 5 states, 10 transitions.Every word up to length 8, one row per length in shortlex order, inked where it is accepted.

The author’s examples, run

101 → accept1010 → accept1100100 → accept111 → reject10011 → reject