Define n!! as

n!! = 1 \* 3 \* 5 \* ... \* n  if n is odd, 

n!! = 2 \* 4 \* 6 \* ... \* n  if n is even. 

Hence 8!! = 2 \* 4 \* 6 \* 8 = 384, there is no zero at the end. 
30!! has 3 zeros at the end. 

For a positive integer n, please count how many zeros are there at 
the end of n!!. 

Example: 

count\_zeros\_n\_double\_fact(30) should return 3

Difficulty: introductory

Starter code:

def count_zeros_n_double_fact(n):
	

Solutions:
def count_zeros_n_double_fact(n): 
    if n % 2 != 0:
        return 0
    k = 0
    while n >= 10:
        k += n // 10
        n //= 5
    return k

def count_zeros_n_double_fact(n):
    return 0 if n%2 == 1 else (n // 6250) + (n // 1250) + (n // 250) + ( n // 50 ) + ( n // 10 ) 

from functools import reduce


def count_zeros_n_double_fact(n): 
    df = n % 2 or reduce(int.__mul__, range(2, n+1, 2), 1)
    return next(i for i, d in enumerate(f"{df}"[::-1]) if d != "0")

from math import log

# n//10 + n//50 + n//250 + n//1250 + ...
def count_zeros_n_double_fact(n):
    return 0 if n&1 else sum(n//2//5**x for x in range(1, int((log(n)-log(2))/log(5))+1))

def count_zeros_n_double_fact(n): 
    return 0 if n % 2 else sum(n // (10 * 5 ** x) for x in range(len(str(n)) + 1))

def count_zeros_n_double_fact(n):
    if n % 2: return 0
    s, n = 0, n // 2
    while n >= 5:
        n //= 5
        s += n
    return s

def count_zeros_n_double_fact(n): 
    if (n % 2 == 1): 
        return 0
    res = 0
    working = n // 2
    while (working > 0): 
        res += working // 5
        working //= 5
    return res

def count_zeros_n_double_fact(n): 
    if n % 2 == 1:
        return 0
    return n // 10 + n // 50 + n // 250

def count_zeros_n_double_fact(n): 
    fact = 1
    while n > 2:
        fact *= n
        n -= 2
    return len(str(fact)) - len(str(fact).rstrip('0'))