Preimage Size of Factorial Zeroes Function

Hard

Description

Let f(x) be the number of trailing zeroes in x!. Given an integer k, return the number of non-negative integers x such that f(x) = k.

Examples

Input:k = 0
Output:5
Explanation:

0!, 1!, 2!, 3!, 4! have 0 trailing zeroes.

Input:k = 5
Output:0
Explanation:

Edge case returning zero.

Input:k = 3
Output:5
Explanation:

Trailing zeroes in x! come from factors of 10=2*5. Since factors of 2 are more abundant, trailing zeroes equal the count of factor 5 in x!. For f(x)=3: f(15)=3, f(16)=3, f(17)=3, f(18)=3, f(19)=3. Five values of x give exactly 3 trailing zeroes.

Constraints

  • 0 ≤ k ≤ 10^9

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!