如何获得计算阶乘以忽略先前阶乘的 while 循环?

How do I get a while loop that is calculating the factorial to disregard the previous factorials?

更新:我已经通过在循环开始时将阶乘重置为 1 并删除不必要的代码来解决复合阶乘的问题。这是新版本。

more = "yes"
while more == "yes":
    n = int(input("Enter a number to get its factorial: "))
    if n >= 0:
        factorial = 1
        for num in range(1, n+1):
            factorial *= num
        print(n,'!=', factorial)
        more = input("Would you like to get another number's factorial?:")
    else:
        print("Factorials are not defined for negative integers.")
print("Thank You!")

您需要在 while 循环开始时将阶乘变量重置为 1。

另外,您需要检查每个输入的 n 是否为正,因为它目前只对第一个输入这样做。