Ai
1 Star 0 Fork 0

子安/Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
factorial_python.py 515 Bytes
一键复制 编辑 原始数据 按行查看 历史
ankitjain4 提交于 2018-10-31 15:28 +08:00 . Create factorial_python.py (#530)
# 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 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/andrewgithub/Python.git
git@gitee.com:andrewgithub/Python.git
andrewgithub
Python
Python
master

搜索帮助