Factorial Function:

def factorial(num: int) -> int:
    """
       Return the product of the numbers from 1 thru num.
       >>> factorial(5)
       120
    """

    if num <= 1:
        return 1
    else:
        return num * factorial(num - 1)

if __name__ == "__main__":
    print("The product of the numbers from 1 thru %d is %d." % (5, factorial(5)))

Use a Stack to solve it