GATE Computer ScienceModerateGATE CS (PYQ pattern)

For how many integers n with 2 ≤ n ≤ 30 does the fraction 1/n have a terminating representation in base 6 but a non-terminating one in base 10?

  1. A. 11
  2. B. 7
  3. C. 4
  4. D. 9

Correct answer: B. 7

1/n terminates in base b exactly when every prime factor of n divides b. Base 6 needs n = 2^a·3^b (> 1): 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27 (11 values). Base 10 needs n = 2^a·5^c; among the 11, the powers of 2 (2, 4, 8, 16) also terminate in base 10. 11 − 4 = 7: 3, 6, 9, 12, 18, 24, 27.

More Digital Logic questions

Exams that ask this topic