Preimage Size of Factorial Zeroes Function
Hard · Math, Binary Search
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 have the property that f(x) = k.
Example 1
Input: k = 0 Output: 5
0!, 1!, 2!, 3!, and 4! end with k = 0 zeroes.
Example 2
Input: k = 5 Output: 0
There is no x such that x! ends in k = 5 zeroes.
Example 3
Input: k = 3 Output: 5
Constraints
- 0 <= k <= 109
Starter code (python)
class Solution(object):
def preimageSizeFZF(self, k):
"""
:type k: int
:rtype: int
"""
Related problems
- Add Two Numbers (Medium)
- Median of Two Sorted Arrays (Hard)
- Reverse Integer (Medium)
Previous: Domino and Tromino Tiling · Next: Rotate String · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.