小白教程
所有教程
关于
Search
172.69.6.34
172.69.6.34
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Ref math factorial”的源代码
本页内容
上一节:
Ref_math_fabs
下一节:
Ref_math_floor
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:math.factorial(x)}}[[Category:python math|25]] = Python math.factorial() 方法 = [[python math|Python math 模块]] Python '''math.factorial(x)''' 方法返回 x 的阶乘。 参数只能是正整数。 一个数字的阶乘是所有整数的乘积之和,例如,6 的阶乘是: 6 x 5 x 4 x 3 x 2 x 1 = 720。 === 语法 === math.factorial() 方法语法如下: <sample title="" desc="" lang="python" hererun="1"> math.factorial(x) </sample> '''参数说明:''' * '''x''' -- 必需,正整数。如果数字为负数或不是整数,则返回 ValueError。 如果值不是数字,则返回 TypeError。 === 返回值 === 返回一个正整数,表示正整数的阶乘。 == 以下实例返回正整数的阶乘: <sample title="" desc="" lang="python" hererun="1"> # 导入 math 包 import math # 输出正整数的阶乘 print(math.factorial(9)) print(math.factorial(6)) print(math.factorial(12)) </sample> 输出结果: <sample title="" desc="" lang="python" hererun="1"> 362880 720 479001600 </sample> [[python math|Python math 模块]]
返回至“
Ref math factorial
”。
上一节:
Ref_math_fabs
下一节:
Ref_math_floor