用Python实现数字的阶乘:
基础写法:
def pythonit():
a = 1
for i in range(1,10):
a = a*i
print(a)
pythonit()
进阶写法:
def python(n):
a = 1
for i in range(1,n=1):
a = a*i
return a
def pythonit():
n = int(input("请输入一个数计算其阶乘:")
result = python(n)
print(f"{n}的阶乘为:{result}")
pythonit()