def double_factorial(n):
    """
    Calculate n!!

    :param n: an integer
    :return: n!!
    """
    if not isinstance(n,int): raise TypeError('n must be an int')
    product = 1
    if n%2 == 1: stop=1
    else: stop=0
    for i in range(n,stop,-2): product *= i
    return product