📜  自动跟踪表制作 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:17.763000             🧑  作者: Mango

代码示例3
num = 7

factorial = 1 
# check if the number is negative, positive or zero
if num < 0:
  print("sorry, factorial does not exist for negative numbers")
  elif num == 0:
    print("the factorial of 0 is 1")
    else:
      limit = num-1
      for i in range(1, limit):
        factorial = factorial*i
        print("the factorial of",num,"is",factorial)