Data Structures & AlgorithmsHardICPC regional · GATE CS

Problem: What is the smallest positive integer n such that n! is divisible by 10⁶ (that is, n! has at least six trailing zeros in base 10)?

  1. A. 30
  2. B. 24
  3. C. 25
  4. D. 6

Correct answer: C. 25

Trailing zeros are limited by factors of 5: v₅(24!) = 4, while v₅(25!) = 5 + 1 = 6 because 25 contributes two 5s, so n = 25. Assuming each multiple of 5 adds exactly one zero gives 6 × 5 = 30, 24 is the last n with too few, and 6 is the number of zeros, not n.

More Coding Interview Problems questions

Exams that ask this topic