python没有自己算阶乘的函数吗

您所在的位置:网站首页 python编写计算阶乘的函数 python没有自己算阶乘的函数吗

python没有自己算阶乘的函数吗

2022-05-14 07:44| 来源: 网络整理| 查看: 265

可以自己写 。

fac = lambda n:reduce(lambda x,y:x*y,range(1,n+1)

import math

math.factorial(x)

有阶乘函数:   

improt numpy

print numpy.math.factorial(3)

python 自带的标准库也有阶乘函数   

import math

print math.factorial(3)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3