# 求N!的值 # fun(n)=n*fun(n-1) , fun(1)=1; # 采用递推的方式 def deTei(num): sxsum = 1; for i in range(1,num+1,1): sxsum =sxsum * i; print(num,"阶乘的值是:",sxsum); # 采用递归的方式 def deGui(num): result = 1; if num == 1 : result = 1; # 回推墙 else : result = deGui(num-1) * num; #递推关系,这个数与上一个数之间的关系。 print("num",num); return result; if __name__ == '__main__': num = int(input("请输入您求的阶乘的数值: ")); deTei(num); print(num,"阶乘的值是:",deGui(num));