geforce
geforce

Reputation: 79

Write a DFA to recognize the following language

The question is:

Write a DFA to recognize the regular language L1 = {w ={1,2,3} | the sum of the digits in w is divisible by 5}

More so, based on the input 1 , 2 , 3 the remainder of the sum should be 0 when dividing by 5. I am almost done this question but I can't seem to understand how to find the correct remainder when the input is 3. Since I have done most of the work I have a picture that I will link so you can understand where I am stuck.

Picture

Start State: q0
Accept State: q0

My problem is how to control the input 3 so the choices for it will lead to a remainder of 0 when dividing by 5.

Upvotes: 1

Views: 537

Answers (1)

templatetypedef
templatetypedef

Reputation: 372664

Here's some hints:

  • Have one state for each possible remainder modulo 5.
  • Given state x and character c, have the transition take you to state (x + c) modulo 5.
  • Think about what your accept state would be given the meaning of your states.

Hope this helps!

Upvotes: 2

Related Questions