Python math.factorial() Method

Math Methods : Find the factorial of a number

Definition and Usage

The math.factorial() method returns the factorial of a number.

Note: This method only accepts positive integers.

The factorial of a number is the sum of the multiplication, of all the whole numbers, from our specified number down to 1. For example, the factorial of 6 would be 6 x 5 x 4 x 3 x 2 x 1 = 720

Syntax

math.factorial(x)

Parameter Values

Parameter Description
x Required. A positive integer. If the number is negative, or not an integer, it returns a ValueError. If the value is not a number, it returns a TypeError

Technical Details

Return Value: A positive int value
Python Version: 2.6