标签:阶乘 number put result else print NPU def cto
def factorial(n):
result = n
for i in range(1, n):
result *= i
return result
number = int(input("请输入一个正整数:"))
result = factorial(number)
print("%d的阶乘是:%d" %(number, result))
-----
def factorial(n):
if n == 1:
return 1
else:
return n* factorial(n - 1)
number = int(input("请输入一个正整数:"))
result = factorial(number)
print("%d的阶乘是:%d" %(number, result))
标签:阶乘 number put result else print NPU def cto
原文地址:http://blog.51cto.com/13842013/2165626