def f(x): if x >= 1: return x*f(x-1) else: return 1 a = int(input("请输入一个数字")) print(f(a))
结果输出:
请输入一个数字5 120 Process finished with exit code 0
def f(x): if x >= 1: return x*f(x-1) else: return 1 a = int(input("请输入一个数字")) print(f(a))
结果输出:
请输入一个数字5 120 Process finished with exit code 0