0

How to detect if a sequence of bits, transmitted MSB first, divides by 3 ? The FSM in below question solves the problem if LSB first. FSM doesn't seem to work because adding '0' bit to left of number doesn't change the value but when adding '1' we get a new value. Why does this FSM accept binary numbers divisible by three?

Meir
  • 1
  • 1
  • edited the question a bit. saw it in a interview question @James – Meir Feb 13 '19 at 12:57
  • You should try to be a lot more clear about what you're asking. For example, an answer to the question as is would be "Just calculate the reminder and compare with 0", but I'm sure that's not what you're looking for. – Todor Markov Feb 13 '19 at 12:59

1 Answers1

1

Hint: I'm assuming you want a FSM that solves the problem, not just any algorithm. Then you can do it by using 6 states. The powers of 2 alternate between 1 and 2 modulo 3, so you need the state to store both the current reminder, and whether you have read odd or even number of digits so far.

Note: The FSM you linked works well if you pass to it the the most significant bit first. Rather, it doesn't work in reverse, so the hint is for FSM that works in reverse.

Todor Markov
  • 2,869