Factorial

n!

gives the factorial of n.

Details

  • Mathematical function, suitable for both symbolic and numerical manipulation.
  • For noninteger 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.
  • Factorial can be used with Interval and CenteredInterval objects. »

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 , z!=TemplateBox[{{z, +, 1}}, Gamma], where the Gamma function TemplateBox[{z}, Gamma] is defined by TemplateBox[{z}, Gamma]=int_0^inftyⅇ^(-t) t^(z-1)dt 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 ^(th) distinct element (so ), the number of permutations equals the multinomial coefficient , given by Multinomial. The multinomial coefficient (n;n_1,...,n_(k)) also counts the ways to partition an -element set into labeled subsets of sizes n1,,nk. Hence the binomial coefficient TemplateBox[{n, m}, Binomial], given by Binomial and defined to count the -element subsets of an -element set, satisfies TemplateBox[{n, m}, Binomial]=(n;m,n-m)=(n!)/(m! (n-m)!).
  • 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 TemplateBox[{{{{(, {n, -, 1}, )}, !}, =, {-, 1}}, n}, Mod] 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, TemplateBox[{Subfactorial, paclet:ref/Subfactorial}, RefLink, BaseStyle -> {InlineFormula}], QFactorial, BarnesG and Pochhammer.

Examples

open allclose all

Basic Examples  (7)

Compute the factorial for the first few integers:

Evaluate at real values:

Plot over a subset of the reals:

Plot over a subset of the complexes:

Series expansion at the origin:

Series expansion at Infinity:

Series expansion at a singular point:

Scope  (34)

Numerical Evaluation  (6)

Evaluate numerically:

Evaluate to high precision:

The precision of the output tracks the precision of the input:

Complex number inputs:

Evaluate efficiently at high precision:

Compute worst-case guaranteed intervals using Interval and CenteredInterval objects:

Or compute average-case statistical intervals using Around:

Compute the elementwise values of an array:

Or compute the matrix Factorial function using MatrixFunction:

Specific Values  (5)

Values of Factorial at fixed points:

Values at zero:

Evaluate for large arguments:

Evaluate for half-integer arguments:

Find the positive minimum of Factorial[x]:

Visualization  (2)

Plot the Factorial function:

Plot the real part of :

Plot the imaginary part of :

Function Properties  (10)

Real domain of the factorial:

Complex domain:

Factorial threads elementwise over lists:

The factorial has the mirror property :

Factorial is not an analytic function:

However, it is a meromorphic function in the complex plane:

Factorial is neither nondecreasing nor nonincreasing:

Factorial is not injective:

Factorial is not surjective:

Factorial is neither non-negative nor non-positive:

Factorial has both singularity and discontinuity for negative integers:

Factorial is neither convex nor concave:

Differentiation  (2)

First derivative with respect to z:

Higher derivatives with respect to z:

Plot the higher derivatives with respect to z:

Series Expansions  (5)

Find the Taylor expansion using Series:

Plots of the first three approximations around :

Find the series expansion at Infinity (Stirling's approximation):

Series at :

Find series expansion for an arbitrary symbolic direction :

Taylor expansion at a generic point:

Recurrence Identities and Simplifications  (2)

Recurrence relations:

For positive integers (n-1)! = TemplateBox[{n}, Gamma]:

Function Representations  (2)

Integral representation of the factorial function:

TraditionalForm formatting:

Generalizations & Extensions  (4)

Evaluate to high precision:

The precision of the output tracks the precision of the input:

Infinite arguments give symbolic results:

Factorial allows derivatives:

Applications  (6)

Make a table of half-integer factorials:

Number of permutations of 6 elements:

Plot of the absolute value of Factorial in the complex plane:

Find the asymptotic expansion of ratios of factorials:

Volume of an ndimensional unit hypersphere:

Lowdimensional cases:

Plot the volume of the unit hypersphere as a function of dimension:

Find the series expansion at -:

Properties & Relations  (9)

Use FullSimplify to simplify expressions involving Factorial:

Compute a generating function sum involving Factorial:

Compute numerical sums involving Factorial:

The generating function is divergent:

Use regularization to obtain a closed-form generating function:

Generating function as a formal series:

Some integrals can be done:

Product of factorials:

Factorial can be represented as a DifferenceRoot:

FindSequenceFunction can recognize the Factorial sequence:

The exponential generating function for Factorial:

Possible Issues  (2)

Large arguments can give results too large to be computed explicitly, even approximately:

Smaller values work:

Machine-number inputs can give highprecision results:

Neat Examples  (3)

Nested factorials over the complex plane:

Plot Factorial at infinity:

Wolfram Research (1988), Factorial, Wolfram Language function, https://reference.wolfram.com/language/ref/Factorial.html (updated 2022).

Text

Wolfram Research (1988), Factorial, Wolfram Language function, https://reference.wolfram.com/language/ref/Factorial.html (updated 2022).

CMS

Wolfram Language. 1988. "Factorial." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/Factorial.html.

APA

Wolfram Language. (1988). Factorial. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Factorial.html

BibTeX

@misc{reference.wolfram_2024_factorial, author="Wolfram Research", title="{Factorial}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Factorial.html}", note=[Accessed: 17-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_factorial, organization={Wolfram Research}, title={Factorial}, year={2022}, url={https://reference.wolfram.com/language/ref/Factorial.html}, note=[Accessed: 17-November-2024 ]}