gives the factorial of n.
- Mathematical function, suitable for both symbolic and numerical manipulation.
- For non‐integer n, the numerical value of n! is given by Gamma[1+n].
- For integers and half integers, Factorial automatically evaluates to exact values.
- Factorial can be evaluated to arbitrary numerical precision.
- Factorial automatically threads over lists.
Background & Context
- Factorial represents the factorial function. In particular, Factorial[n] returns the factorial of a given number , which, for positive integers, is defined as . For n1,2,…, the first few values are therefore 1,2,6,24,120,720,…. The special case is defined as 1, consistent with the combinatorial interpretation of there being exactly one way to arrange zero objects. For a general complex number , , where the Gamma function is defined by for all complex values of except when is a negative integer (in which case is complex infinity). Factorials of half integers are given by rational multiples of .
- Factorials are best known for counting fixed orderings of the elements of a list, known as permutations, which can be generated using Permutations. There are permutations of a list of (distinct) elements, a fact that follows from there being spots to place the first element, spots to place the second element once the first is placed, spots to place the third element once the first two elements are placed and so on until a single spot remains in which to place the last element. There are therefore permutations of , namely , , , , and .
- More generally, for an -element multiset having distinct elements with copies of the distinct element (so ), the number of permutations equals the multinomial coefficient , given by Multinomial. The multinomial coefficient also counts the ways to partition an -element set into labeled subsets of sizes n1,…,nk. Hence the binomial coefficient , given by Binomial and defined to count the -element subsets of an -element set, satisfies .
- The factorial function satisfies the recurrences and . It grows faster than any exponential function, as shown by Stirling's approximation . Factorials also appear in fundamental results in number theory and analysis. Wilson's theorem states that if and only if is prime. If is an infinitely differentiable scalar function, then its Taylor series representation about a point (computable using Series) is given by . Setting and in the Taylor series of the exponential function yields the beautiful identity for E (the base of the natural logarithm) .
- Other functions associated with or generalizing Factorial include Factorial2, FactorialPower, , QFactorial, BarnesG and Pochhammer.
Examplesopen allclose all
Introduced in 1988