def factorial(num):
    """Compute factorial of a number."""

    result = 1
    if num < 0:
        raise Exception('ValueError: factorial() not defined for negative values')
    elif num == 0:
        return result
    else:
        for i in range(1, num + 1):
            result = result * i
        return result