def problem_19_3(n):
    """ Write an algorithm which computes the number of trailing zeros in
    n factorial.

    Solution: It's enough to count the power of 5 in the factoring of n!
    That is the number of trailing zeros.
    """
    cache = {}

    def get_pow_5(n):
        if n % 5 != 0:
            return 0
        if n in cache:
            return cache[n]
        pow_5 = 1 + get_pow_5(n/5)
        cache[n] = pow_5
        return pow_5

    # Trailing zeroes are composed of multiples of 2 and 5.
    count_pow_5 = 0
    for i in range(2, n+1):
        pow_5 = get_pow_5(i)
        count_pow_5 += pow_5

    return count_pow_5