Preimage Size of Factorial Zeroes Function

Let f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 * 3 * ... * x and, by convention, 0! = 1.

Given an integer k, return the number of non-negative integers x that have the property that f(x) = k.

Example 1
Inputk = 0
Output5
0!, 1!, 2!, 3!, and 4! end with k = 0 zeroes.
Example 2
Inputk = 5
Output0
There is no x such that x! ends in k = 5 zeroes.

Constraints

  • 0 <= k <= 10^9

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate