Dsa
Math
Medium
Compute Factorial Trailing Zeros
Given a non-negative integer n, calculate the number of trailing zeros in n!. The number of trailing zeros in a factorial is determined by the number of times 10 is a factor in the product. Since 10 is made by multiplying 2 and 5, and there are always more factors of 2, you need to count the factors of 5. Input a single integer, and output the number of trailing zeros in its factorial.
Example Input:
25
Example Output:
6
Key concepts
factorialtrailing zerocombinatorics
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now