← Back to challenges

Factorial Trailing Zeroes

PythonHardmathnumbers

Instructions

Given an integer n, return the number of trailing zeroes in n!.

Examples

trailing_zeroes(6) ➞ 1
# factorial(6) = 720

trailing_zeroes(30) ➞ 7
# factorial(30) = 265252859812191058636308480000000

Notes

Create a solution that works in logarithmic time complexity.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.