Trains the technique from
LeetCode 172Factorial Trailing ZeroesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
At the close of a production run the log posts one figure: the shift numbers 1, 2, up to n all multiplied together. A run of no shifts posts the figure 1.
Write the posted figure in decimal. Return how many zeros stand to the right of its last non-zero digit. Aim for a running time that grows only with the logarithm of n, since for n near the upper bound the figure itself runs to tens of thousands of digits.
Example 1
The figure posted for 24 shifts is 620448401733239439360000, which ends in four zeros before its last non-zero digit 6.
Example 2
The figure for 124 shifts is a 208-digit number ending with 28 zeros, so 28 is returned.
Example 3
The figure for 1249 shifts ends with 308 zeros.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def trailing_zeroes(n: int) -> int:public int trailingZeroes(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.