#C8467. Trailing Zeroes in Factorial
Trailing Zeroes in Factorial
Trailing Zeroes in Factorial
Given a non-negative integer n, compute the number of trailing zeroes in n! (n factorial).
The trailing zeroes in n! are determined by the number of pairs of factors 2 and 5 in its prime factorization. Since there are usually more factors of 2 than 5, the count of trailing zeroes is governed by the number of times 5 appears as a factor.
This can be mathematically expressed as:
$$ \text{trailing zeroes} = \sum_{i=1}^{\infty} \left\lfloor \frac{n}{5^i} \right\rfloor $$
The summation terminates when \(5^i > n\).
inputFormat
The input consists of a single integer n (0 ≤ n ≤ 109) representing the number for which the trailing zeroes in its factorial are to be computed.
The input is provided via standard input (stdin).
outputFormat
Output a single integer which is the number of trailing zeroes in n!.
The output should be written to standard output (stdout).
## sample5
1