def fun(num): sum = 1 if num > 1: sum = num * (num - 1) num = num - 1 sum = sum * ( num - 1 ) fun(num-1) return sum while True: num = input('输入一个数>>').strip() if num.isdigit(): res = fun(int(num)) print(res) break else: print('请重新输入')
def fun(num): sum = 1 if num > 1: sum = num * (num - 1) num = num - 1 sum = sum * ( num - 1 ) fun(num-1) return sum while True: num = input('输入一个数>>').strip() if num.isdigit(): res = fun(int(num)) print(res) break else: print('请重新输入')