Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Factorial Zeros by PythonLearner
def count_devisors(number: int, devisor: int) -> int:
count = 0
while number%devisor == 0:
number //= devisor
count += 1
return count
def fact_zeros(n: int) -> int:
twos = 0
fives = 0
for i in range(2, n+1):
twos += count_devisors(i, 2)
fives += count_devisors(i, 5)
return min(twos, fives)
print("Example:")
print(fact_zeros(2))
# These "asserts" are used for self-checking
assert fact_zeros(2) == 0
assert fact_zeros(5) == 1
assert fact_zeros(20) == 4
print("The mission is done! Click 'Check Solution' to earn rewards!")
Feb. 22, 2024
Comments: