def factorial(n):
    """
    Calculate a factorial $n!$
    Args:     
        n (int): the total number of trials
    Returns:
        int: factorial result
    """
    return 1 if n == 0 else n*factorial(n-1)