python 阶乘(n!)
使用for循环实现阶乘
a = int(input('please input a interger: ')) num = 1 if a < 0: print('负数没有阶乘!') elif a == 0: print('0的阶乘是1') else: for i in range(1,a+1): num *= i print(num)
使用for循环实现阶乘
a = int(input('please input a interger: ')) num = 1 if a < 0: print('负数没有阶乘!') elif a == 0: print('0的阶乘是1') else: for i in range(1,a+1): num *= i print(num)