Skip to content

Mathematics — API

factorial(n)

Compute factorial (mathematical shortcut !) of a non negative integer number

All Napoleon sections have been added to this docstring to see how they get rendered.
Some wierd behavior depending on a : being present in the text string…
To be investigated.

Parameters:

Name Type Description Default
n int

number to factor, must be an non negative integer value.

required

Raises:

Type Description
ValueError

supplied argument is not zero or or a positive integer.

Returns:

Type Description
int

factorial of supplied integer argument.

Warning

Value can quickly become quite large.

Examples:

>>> factorial(4)
24
>>> factorial(0)
1
>>> factorial(-2)
not non negative integer
ValueError
>>> factorial(3.4)
not non negative integer
ValueError
See Also

I love airports.