GATE Computer ScienceHardGATE CSE

A DFA reads 12-bit strings (MSB first) and accepts exactly those whose binary value is divisible by 7 (the all-zeros string included). How many of the 4096 strings of length 12 are accepted?

  1. A. 585
  2. B. 593
  3. C. 579
  4. D. 586

Correct answer: D. 586

The values 0, 7, 14, …, 4095 − (4095 mod 7) = 4095 are multiples of 7: ⌊4095/7⌋ + 1 = 585 + 1 = 586.

More Theory of Computation questions

Exams that ask this topic