I have to program a DFA which has to do the following for an input of binary 5 my task told me to use a finite memory

`0 0 1 1 2 3 2 4 0 3 1 2 4 3 4 `

qi−1 δ(qi−1,0) δ(qi−1,1) these are the rows

Where i have the transition function If input is 1 then

q= (2*q)+1 % n (and i guess this is one memory)

otherwise if input is 0 then

q = 2q % n (also memory phase)

Now i came to the fourth row there the struggle starts I have no more input

Now, can i “memorize” each read symbol and a counter So if i reach an end i could test of my memorized binary number minus my counter is not zero and if it is no zero i will continue with the value?

Otherwise it reached it’s final state Is this legit?

I have a limit of states that should be m mod n