The factorial is a function that assigns to each nonnegative integer the product of all positive integers from through . Written and read “ factorial,” it includes the convention . Factorials are fundamental in combinatorics, particularly for counting arrangements of distinct objects, and also appear in mathematical analysis and scientific computation. (reference.wolfram.com)
Definition and elementary properties
For a positive integer ,
For example, and . Beginning with , the first values are
The exclamation mark denotes this multiplication operation, not punctuation or exponentiation. (reference.wolfram.com)
An equivalent recurrence relation is
The zero case agrees with the convention that an empty product equals the multiplicative identity, . It also has a counting interpretation: there is exactly one ordering of a collection containing no objects—the empty ordering. Consequently, formulas involving factorials remain valid at boundary cases such as selecting no objects. (reference.wolfram.com)
Successive factorials satisfy . This allows common factors to be canceled without evaluating either factorial fully. For example, . These identities follow directly from the product definition. (reference.wolfram.com)
Counting arrangements and selections
A permutation is an ordering of distinct objects. There are permutations of objects: the first position has possible occupants, the second has , and successive positions have progressively fewer choices. Multiplication gives . Three distinct objects therefore have six possible orderings. (math.dartmouth.edu)
If only objects are selected and their order matters, the number of arrangements without repetition is
If order does not matter, each selected subset has been counted times. Dividing by this number gives the binomial coefficient,
Thus five distinct objects yield twenty ordered selections of two objects, but only ten unordered selections. (math.dartmouth.edu)
When objects include indistinguishable copies, the count changes. If objects belong to category , with , their distinct orderings number
This multinomial coefficient removes the overcounting caused by exchanges among identical copies. For instance, the letters A, A, and B have three distinct orderings rather than six. (reference.wolfram.com)
Factorials in mathematical analysis
Factorials appear naturally in Taylor series. For an analytic function expanded around ,
within its region of convergence. The denominator compensates for the factor produced by taking the th derivative of . The resulting coefficients encode the function’s successive derivatives at the expansion point. (dlmf.nist.gov)
A prominent example is the exponential function:
This power series converges for every real or complex . Setting expresses as the sum of reciprocal factorials. Factorials therefore connect finite counting problems with infinite expansions of continuous functions. (dlmf.nist.gov)
Growth and approximation
Factorials increase rapidly. Their size for large is described by Stirling’s approximation:
The symbol means that the ratio of the two expressions approaches as tends to infinity; it does not indicate exact equality at finite . (dlmf.nist.gov)
A refined asymptotic expansion begins
Here big-O notation describes the order of the remaining correction. Taking logarithms gives
These formulas imply that factorial growth eventually exceeds for every fixed positive constant . The logarithmic form describes magnitude without requiring the enormous integer itself. (dlmf.nist.gov)
Extension through the gamma function
The gamma function extends factorial values beyond integers. For a complex number with positive real part, it is defined by the integral
For every nonnegative integer ,
Accordingly, the conventional extension is . This is an extension of the product definition, not a product containing a noninteger number of factors. (dlmf.nist.gov)
Through analytic continuation, this extension is defined throughout the complex plane except at negative integers, where it has poles. It assigns finite values to many noninteger arguments; for example,
The original factorial on nonnegative integers and its gamma-based extension should therefore be distinguished by their domains. (dlmf.nist.gov)
Computation
The recurrence provides a direct algorithm: start with and multiply successively by . This is a mathematical consequence of the definition and can be expressed using iteration or recursion. Exact factorials and approximate gamma values are distinct computational operations; Python’s mathematical library, for example, provides separate functions for them. (reference.wolfram.com)
For logarithmic calculations, . A log-gamma routine can evaluate this quantity without first forming . Such a result describes the factorial’s logarithm rather than its exact integer value, an important distinction when choosing a numerical representation. (dlmf.nist.gov)