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.

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  (0)

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (7)

Generalizations & Extensions  (4)

Applications  (6)

Properties & Relations  (9)

Possible Issues  (2)

Neat Examples  (2)

See Also

Gamma  Binomial  Pochhammer  Factorial2  FactorialPower  Subfactorial  QFactorial

Tutorials

Introduced in 1988
(1.0)