How to use python factorial function

(*-*)浩
Release: 2019-07-03 10:08:17
Original
23501 people have browsed it

There are two factorial functions in python, and those created by yourself are not counted.

How to use python factorial function

The first is the factorial function in the numpy library (recommended learning: Python video tutorial)

improt numpy
print numpy.math.factorial(3)
Copy after login

Second, the standard library that comes with python also has the factorial function

import math
print math.factorial(3)
Copy after login

Example:

#由于第一种需要下载库,我们使用第二种
import math
value = math.factorial(3)    
print(value)
Copy after login

Output:

6
Copy after login

For more Python-related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to use python factorial function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template