Smallest Factorial With K Zeros
The number n! (n factorial) is 1 * 2 * ... * n. Return the smallest n for which n! ends in exactly k zeros, or -1 if no factorial ends in exactly k zeros.
Example 1
k 3
returns 15
15! is the first factorial with three factors of 5 (from 5, 10 and 15), and each one makes a zero.
Example 2
k 5
returns -1
24! ends in four zeros and 25! ends in six, because 25 brings two factors of 5 at once.
Constraints
1 <= k <= 10**9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Times a Digit Is WrittenHard
- Ways as a Run of NumbersHard
- Alternating Digit SumBeginner
- Armstrong NumberBeginner
- Base K to DecimalBeginner
- Collatz StepsBeginner
- Count DivisorsBeginner
- Decimal to Binary StringBeginner