def fact(n): if n==0: return 1 else: return n*fact(n-1)
n=int(input()) print(fact(n)) 本回答被网友采纳
第2个回答 2018-05-15
def factorial(num):#num=3 """ 使用递归法求阶乘 """ sum = 0 while num > 0: if num > 1: sum+=num*factorial(num-1) num-=1 return sum else: return 1 # pass num = int(input("请输入想要求的阶乘:\n")) result = factorial(num)