1 Star 0 Fork 0

问天/Python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
factorial_python.py 531 Bytes
一键复制 编辑 原始数据 按行查看 历史
PatOnTheBack 提交于 2019-07-02 12:05 +08:00 . Improve Formatting and Code Quality (#934)
"""Python program to find the factorial of a number provided by the user."""
# change the value for a different result
NUM = 10
# uncomment to take input from the user
# num = int(input("Enter a number: "))
FACTORIAL = 1
# check if the number is negative, positive or zero
if NUM < 0:
print("Sorry, factorial does not exist for negative numbers")
elif NUM == 0:
print("The factorial of 0 is 1")
else:
for i in range(1, NUM + 1):
FACTORIAL = FACTORIAL * i
print("The factorial of", NUM, "is", FACTORIAL)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/henrysec/Python.git
git@gitee.com:henrysec/Python.git
henrysec
Python
Python
master

搜索帮助