Skip to main content
why
Source Link

This should be quicker than the recursiveRecursion adds overhead, especially in memory but also in time, compared to this purely iterative version:

def zeros(n):
    z = 0
    while n >= 5:
        n = n//5
        z = z+n
    return z

This should be quicker than the recursive version:

def zeros(n):
    z = 0
    while n >= 5:
        n = n//5
        z = z+n
    return z

Recursion adds overhead, especially in memory but also in time, compared to this purely iterative version:

def zeros(n):
    z = 0
    while n >= 5:
        n = n//5
        z = z+n
    return z
Source Link

This should be quicker than the recursive version:

def zeros(n):
    z = 0
    while n >= 5:
        n = n//5
        z = z+n
    return z