Counting trailing zeros in 100 factorial
Trailing zeros in one hundred factorial is an easy quant interview question on Brain Teasers.
This question focuses on understanding how the decimal representation of a factorial ends, specifically how many zeros appear at the end of a very large product. The setup is a straightforward pure mathematics exercise: take a moderately large factorial and reason about its prime factorization without actually computing the number itself. It is a staple of early number theory and combinatorics practice, and is common in written tests or online screens for quantitative and technical roles because it links a familiar notion (trailing zeros) to a deeper structural property of integers.
To answer it, a candidate must connect trailing zeros to factors of 10, then reduce that to counting specific prime factors inside a factorial. The key technique is expressing the factorial's prime exponent via a sum over integer divisions, including contributions from higher powers of a prime. Interviewers look for fluency with prime factorization, comfort with floor functions and series-like sums, and the ability to generalize the reasoning beyond the specific numerical case. They may also watch for clear, organized calculation rather than ad hoc counting.
What it tests
Whenever you are asked about the number of trailing zeros in a factorial, the core structure is about prime factorization: specifically, how many times the factorial's product can be divided by 10. Since 10 factors as 2 times 5, and factorials always have more factors of 2 than 5, the number of trailing zeros is always determined by the limiting factor: the number of times 5 appears in the prime factorization. This is found by summing the integer divisions of $n$ by 5, 25, 125, etc., because each higher power of 5 contributes additional factors. The principle holds because every multiple of 5 contributes at least one 5, every multiple of 25 contributes an extra, and so on, reflecting the way exponents accumulate in prime factorizations.
Practise this question with written feedback, or hear it in a spoken mock interview.
Get started free