利用while循环计算从1*2*3*4*......*100的数值
"""利用while循环计算从1*2*3*4*......*100的数值"""a=2
b=1
while b<=100:
a=b*a
b=b+1
print(a)
186652430887888305363398477712533400981431936528763242937185927790435199986459831217882927952313036572507395841654447516502370421833728000000000000000000000000
用for循环{:10_256:}
a = 1
for i in range(1, 101):
a *= i
print(a)
元豪 发表于 2023-3-18 17:08
用for循环
多谢大佬 用递归{:10_256:}:
def digui(i):
if i == 100:
return i
else:
return i * digui(i + 1)
print(digui(1))
@元豪 学习编程中的Ben 发表于 2023-3-18 21:27
用递归:
那假如是1*2*3*......*10000呢{:10_256:}
a = 1
for i in range(1, 10001):
a *= i
print(a)
页:
[1]