Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: How many trailing zeros does 1000! have in base 10?

  1. A. 200
  2. B. 240
  3. C. 250
  4. D. 249

Correct answer: D. 249

Trailing zeros = factors of 5 in 1000! = 200 + 40 + 8 + 1 = 249 (factors of 2 are plentiful). Stopping at 1000/5 gives 200, at the 25-term gives 240, and the shortcut 1000/4 = 250 ignores the floors.

More Coding Interview Problems questions

Exams that ask this topic