【发布时间】:2024-05-21 22:00:02
【问题描述】:
我正在寻找 N 的因子!但是我们不能使用阶乘函数,我输入的方程给我的数字几乎是正确的,但不像我输入 10 时它给我 36288000,而它应该给我 3628800
声明 getInt()
def getInt():
getInt = int
done = False
while not done:
#写“这个程序计算N!”
print("This program calcultes N!")
# 获取“N”的输入
N = int(input("Please enter a non-negative value for N: "))
# if N < 0 then
if N < 0:
print("Non-Negative integers, please!")
# else
else:
# done = true
done = True
# return N
return N
主要
def main():
n = getInt()
for i in range(n):
n = n * (i+1)
print("=",n)
main()
【问题讨论】:
标签: python-3.x for-loop while-loop equation raptor