Data Structures & AlgorithmsModerateTCS NQT · ICPC regional

Problem: Compute the number of trailing zeros of 25! in base 5 (that is, how many times 5 divides 25!).

  1. A. 5
  2. B. 1
  3. C. 6
  4. D. 22

Correct answer: C. 6

Legendre: 25 // 5 + 25 // 25 = 5 + 1 = 6. Counting only multiples of 5 gives 5, counting only 25 gives 1, and 22 is the power of 2 in 25!.

More Coding Interview Problems questions

Exams that ask this topic