Library

DFA · Regular

Lengths divisible by 2 or by 3

A unary language is ultimately periodic. Here the period is lcm(2, 3) = 6: a ring of six states, four of them accepting — 0, 2, 3 and 4.

n0n1n2n3n4n5aaaaaa
The machine as drawn — 6 states, 6 transitions.Every word up to length 14, one row per length in shortlex order, inked where it is accepted.

The author’s examples, run

ε → acceptaa → acceptaaa → acceptaaaaaaaaaaaaaa → accepta → rejectaaaaaaaaaaaaa → rejectaaaaa → rejectaaaaaaa → reject