代码拉取完成,页面将自动刷新
import math
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
n = int(input("Input a number to compute the factiorial : "))
print(factorial(n))
"""
Method 2:
Here we are going to use in-built fuction for factorial which is provided by Python for
user conveniance.
Steps:
-For this you should import math module first
-and use factorial() method from math module
Note:
Appear error when pass a negative or fraction value in factorial() method, so plz refrain from this.
Let's code it:
"""
if n>=0 :
print(math.factorial(n))
else:
print("Value of n is inValid!")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。