I was given a task to find RE and NFA for a word that is divisible by 5.
∑ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
- String passed to RE could be of any length
- You may also allowed to sub divide ∑ into more than one sets
I want to verify my attempted solution.
Let A = {1, 2, 3, 4, 6, 7, 8, 9}
Let B = {0, 5}
We know the numbers divisible by 5 always end at 0 or 5. Therefore the RE that would accept any number that is divisibly by 5 is
(a*b*)*b
Few examples to verify the RE.
The NFA I drew is
My question is, are my answers correct? If not then what's the mistake I made.


If you separate zero, i.e. A = {1, 2, 3, 4, 6, 7, 8, 9}, B = {5}, C={0} then you can write RE like this: $(c|((a|b)(a*b*c*)*(b|c)))$