All problems

Factorial Trailing Zeroes

Medium · math

The factorial of a non-negative integer n, written n!, is the product 1 * 2 * 3 * ... * n, and 0! is defined as 1. For example 5! = 120, which ends in one zero.

Given n, return the number of trailing zeros in the decimal form of n!, meaning the zeros at the very end of the number.

Examples

Example 1

Input: n = 5

Output: 1

5! = 120, which ends in one zero.

Example 2

Input: n = 10

Output: 2

10! = 3628800, which ends in two zeros.

Example 3

Input: n = 3

Output: 0

3! = 6 has no trailing zeros.

Constraints