Factorial
Encyclopedia
In mathematics
Mathematics
Mathematics is the study of quantity, space, structure, and change. Mathematicians seek out patterns and formulate new conjectures. Mathematicians resolve the truth or falsity of conjectures by mathematical proofs, which are arguments sufficient to convince other mathematicians of their validity...

, the factorial of a non-negative integer n, denoted by n!, is the product
Product (mathematics)
In mathematics, a product is the result of multiplying, or an expression that identifies factors to be multiplied. The order in which real or complex numbers are multiplied has no bearing on the product; this is known as the commutative law of multiplication...

 of all positive integers less than or equal to n. For example,

The value of 0! is 1, according to the convention for an empty product
Empty product
In mathematics, an empty product, or nullary product, is the result of multiplying no factors. It is equal to the multiplicative identity 1, given that it exists for the multiplication operation in question, just as the empty sum—the result of adding no numbers—is zero, or the additive...

.

The factorial operation is encountered in many different areas of mathematics, notably in combinatorics
Combinatorics
Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures. Aspects of combinatorics include counting the structures of a given kind and size , deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria ,...

, algebra
Algebra
Algebra is the branch of mathematics concerning the study of the rules of operations and relations, and the constructions and concepts arising from them, including terms, polynomials, equations and algebraic structures...

 and mathematical analysis
Mathematical analysis
Mathematical analysis, which mathematicians refer to simply as analysis, has its beginnings in the rigorous formulation of infinitesimal calculus. It is a branch of pure mathematics that includes the theories of differentiation, integration and measure, limits, infinite series, and analytic functions...

. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e., permutation
Permutation
In mathematics, the notion of permutation is used with several slightly different meanings, all related to the act of permuting objects or values. Informally, a permutation of a set of objects is an arrangement of those objects into a particular order...

s of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars.
The notation n! was introduced by Christian Kramp
Christian Kramp
Christian Kramp was a French mathematician, who worked primarily with factorials.Christian Kramp's father was his teacher at grammar school in Strasbourg. Kramp studied medicine and graduated, however, his interests certainly ranged outside medicine for, in addition to a number of medical...

 in 1808.

The definition of the factorial function can also be extended to non-integer arguments, while retaining its most important properties; this involves more advanced mathematics, notably techniques from mathematical analysis.

Definition

The factorial function is formally defined by


or recursively
Recursion
Recursion is the process of repeating items in a self-similar way. For instance, when the surfaces of two mirrors are exactly parallel with each other the nested images that occur are a form of infinite recursion. The term has a variety of meanings specific to a variety of disciplines ranging from...

 defined by


Both of the above definitions incorporate the instance


in the first case by the convention that the product of no numbers at all
Empty product
In mathematics, an empty product, or nullary product, is the result of multiplying no factors. It is equal to the multiplicative identity 1, given that it exists for the multiplication operation in question, just as the empty sum—the result of adding no numbers—is zero, or the additive...

 is 1. This is convenient because:
  • There is exactly one permutation of zero objects (with nothing to permute, "everything" is left in place).
  • The recurrence relation
    Recurrence relation
    In mathematics, a recurrence relation is an equation that recursively defines a sequence, once one or more initial terms are given: each further term of the sequence is defined as a function of the preceding terms....

     , valid for n > 0, extends to n = 0.
  • It allows for the expression of many formulas, like the exponential function
    Exponential function
    In mathematics, the exponential function is the function ex, where e is the number such that the function ex is its own derivative. The exponential function is used to model a relationship in which a constant change in the independent variable gives the same proportional change In mathematics,...

     as a power series:
  • It makes many identities in combinatorics
    Combinatorics
    Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures. Aspects of combinatorics include counting the structures of a given kind and size , deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria ,...

     valid for all applicable sizes. The number of ways to choose 0 elements from the empty set
    Empty set
    In mathematics, and more specifically set theory, the empty set is the unique set having no elements; its size or cardinality is zero. Some axiomatic set theories assure that the empty set exists by including an axiom of empty set; in other theories, its existence can be deduced...

     is . More generally, the number of ways to choose (all) n elements among a set of n is .


The factorial function can also be defined for non-integer values using more advanced mathematics, detailed in the section below. This more generalized definition is used by advanced calculator
Calculator
An electronic calculator is a small, portable, usually inexpensive electronic device used to perform the basic operations of arithmetic. Modern calculators are more portable than most computers, though most PDAs are comparable in size to handheld calculators.The first solid-state electronic...

s and mathematical software
Mathematical software
Mathematical software is software used to model, analyze or calculate numeric, symbolic or geometric data.-Computer algebra systems:Many mathematical suites are computer algebra systems that use symbolic mathematics. They are designed to solve classical algebra equations and problems in human...

 such as Maple
Maple (software)
Maple is a general-purpose commercial computer algebra system. It was first developed in 1980 by the Symbolic Computation Group at the University of Waterloo in Waterloo, Ontario, Canada....

 or Mathematica
Mathematica
Mathematica is a computational software program used in scientific, engineering, and mathematical fields and other areas of technical computing...

.

Applications

Although the factorial function has its roots in combinatorics
Combinatorics
Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures. Aspects of combinatorics include counting the structures of a given kind and size , deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria ,...

, formulas involving factorials occur in many areas of mathematics.
  • There are n! different ways of arranging n distinct objects into a sequence, the permutation
    Permutation
    In mathematics, the notion of permutation is used with several slightly different meanings, all related to the act of permuting objects or values. Informally, a permutation of a set of objects is an arrangement of those objects into a particular order...

    s of those objects.

  • Often factorials appear in the denominator of a formula to account for the fact that ordering is to be ignored. A classical example is counting k-combination
    Combination
    In mathematics a combination is a way of selecting several things out of a larger group, where order does not matter. In smaller cases it is possible to count the number of combinations...

    s (subsets of k elements) from a set with n elements. One can obtain such a combination by choosing a k-permutation: successively selecting and removing an element of the set, k times, for a total of
possibilities. This however produces the k-combinations in a particular order that one wishes to ignore; since each k-combination is obtained in k! different ways, the correct number of k-combinations is
This number is known as the binomial coefficient
Binomial coefficient
In mathematics, binomial coefficients are a family of positive integers that occur as coefficients in the binomial theorem. They are indexed by two nonnegative integers; the binomial coefficient indexed by n and k is usually written \tbinom nk , and it is the coefficient of the x k term in...

 , because it is also the coefficient of Xk in .

  • Factorials occur in algebra
    Algebra
    Algebra is the branch of mathematics concerning the study of the rules of operations and relations, and the constructions and concepts arising from them, including terms, polynomials, equations and algebraic structures...

     for various reasons, such as via the already mentioned coefficients of the binomial formula, or through averaging over permutations for symmetrization
    Symmetrization
    In mathematics, symmetrization is a process that converts any function in n variables to a symmetric function in n variables.Conversely, anti-symmetrization converts any function in n variables into an antisymmetric function.-2 variables:...

     of certain operations.

  • Factorials also turn up in calculus
    Calculus
    Calculus is a branch of mathematics focused on limits, functions, derivatives, integrals, and infinite series. This subject constitutes a major part of modern mathematics education. It has two major branches, differential calculus and integral calculus, which are related by the fundamental theorem...

    ; for example they occur in the denominators of the terms of Taylor's formula, basically to compensate for the fact that the n-th derivative
    Derivative
    In calculus, a branch of mathematics, the derivative is a measure of how a function changes as its input changes. Loosely speaking, a derivative can be thought of as how much one quantity is changing in response to changes in some other quantity; for example, the derivative of the position of a...

     of xn is n!.

  • Factorials are also used extensively in probability theory
    Probability theory
    Probability theory is the branch of mathematics concerned with analysis of random phenomena. The central objects of probability theory are random variables, stochastic processes, and events: mathematical abstractions of non-deterministic events or measured quantities that may either be single...

    .

  • Factorials can be useful to facilitate expression manipulation. For instance the number of k-permutations of n can be written as
while this is inefficient as a means to compute that number, it may serve to prove a symmetry property of binomial coefficients:

Number theory

Factorials have many applications in number theory
Number theory
Number theory is a branch of pure mathematics devoted primarily to the study of the integers. Number theorists study prime numbers as well...

. In particular, n! is necessarily divisible by all prime number
Prime number
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2...

s up to and including n. As a consequence, n > 5 is a composite number
Composite number
A composite number is a positive integer which has a positive divisor other than one or itself. In other words a composite number is any positive integer greater than one that is not a prime number....

 if and only if
If and only if
In logic and related fields such as mathematics and philosophy, if and only if is a biconditional logical connective between statements....



A stronger result is Wilson's theorem, which states that
if and only if p is prime.

Adrien-Marie Legendre
Adrien-Marie Legendre
Adrien-Marie Legendre was a French mathematician.The Moon crater Legendre is named after him.- Life :...

 found that the multiplicity of the prime p occurring in the prime factorization of n! can be expressed exactly as

This fact is based on counting the number of factors p of the integers from 1 to n. The number of multiples of p in the numbers 1 to n are given by ; however, this formula counts those numbers with two factors of p only once. Hence another factors of p must be counted too. Similarly for three, four, five factors, to infinity. The sum is finite since p i can only be less than or equal to n for finitely many values of i, and the floor function results in 0 when applied for p i > n.

The only factorial that is also a prime number is 2, but there are many primes of the form n! ± 1, called factorial prime
Factorial prime
A factorial prime is a prime number that is one less or one more than a factorial . The first few factorial primes are:n! − 1 is prime for :n! + 1 is prime for :...

s.

All factorials greater than 0! and 1! are even, as they are all multiples of 2. Also, all factorials greater than 5! are multiples of 10 (and hence have a trailing zero
Trailing zero
In mathematics, trailing zeros are a sequence of 0s in the decimal representation of a number, after which no other digits follow....

 as their final digit), because they are multiples of 5 and 2.

Also note that the reciprocal
Reciprocal
-In mathematics:*Multiplicative inverse, in mathematics, the number 1/x, which multiplied by x gives the product 1, also known as a reciprocal*Reciprocal rule, a technique in calculus for calculating derivatives of reciprocal functions...

s of factorials produce a convergent series: (see e
E (mathematical constant)
The mathematical constant ' is the unique real number such that the value of the derivative of the function at the point is equal to 1. The function so defined is called the exponential function, and its inverse is the natural logarithm, or logarithm to base...

)

Rate of growth and approximations for large n

As n grows, the factorial n! becomes larger than all polynomial
Polynomial
In mathematics, a polynomial is an expression of finite length constructed from variables and constants, using only the operations of addition, subtraction, multiplication, and non-negative integer exponents...

s and exponential function
Exponential function
In mathematics, the exponential function is the function ex, where e is the number such that the function ex is its own derivative. The exponential function is used to model a relationship in which a constant change in the independent variable gives the same proportional change In mathematics,...

s (but slower than double exponential functions) in n.

Most approximations for n! are based on approximating its natural logarithm
Natural logarithm
The natural logarithm is the logarithm to the base e, where e is an irrational and transcendental constant approximately equal to 2.718281828...



The graph of the function f(n) = log n! is shown in the figure on the right. It looks approximately linear
Linear function
In mathematics, the term linear function can refer to either of two different but related concepts:* a first-degree polynomial function of one variable;* a map between two vector spaces that preserves vector addition and scalar multiplication....

 for all reasonable values of n, but this intuition is false.
We get one of the simplest approximations for log n! by bounding the sum with an integral
Integral
Integration is an important concept in mathematics and, together with its inverse, differentiation, is one of the two main operations in calculus...

 from above and below as follows:


which gives us the estimate


Hence log n! is Θ(n log n). This result plays a key role in the analysis of the computational complexity
Computational complexity theory
Computational complexity theory is a branch of the theory of computation in theoretical computer science and mathematics that focuses on classifying computational problems according to their inherent difficulty, and relating those classes to each other...

 of sorting algorithm
Sorting algorithm
In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order...

s (see comparison sort
Comparison sort
A comparison sort is a type of sorting algorithm that only reads the list elements through a single abstract comparison operation that determines which of two elements should occur first in the final sorted list...

).

From the bounds on log n! deduced above we get that


It is sometimes practical to use weaker but simpler estimates. Using the above formula it is easily shown that for all n we have , and for all n ≥ 6 we have .

For large n we get a better estimate for the number n! using Stirling's approximation
Stirling's approximation
In mathematics, Stirling's approximation is an approximation for large factorials. It is named after James Stirling.The formula as typically used in applications is\ln n! = n\ln n - n +O\...

:


In fact, it can be proved that for all n we have


A much better approximation for was given by Srinivasa Ramanujan
Srinivasa Ramanujan
Srīnivāsa Aiyangār Rāmānujan FRS, better known as Srinivasa Iyengar Ramanujan was a Indian mathematician and autodidact who, with almost no formal training in pure mathematics, made extraordinary contributions to mathematical analysis, number theory, infinite series and continued fractions...

 

Computation

Computing factorials is trivial from an algorithmic point of view: successively multiplying a variable initialized to 1 by the integers 2 up to n (if any) will compute n!, provided the result fits in the variable. In functional languages, the recursive definition is often implemented directly to illustrate recursive functions.

The main difficulty in computing factorials is the size of the result. To assure that the result will fit for all legal values of even the smallest commonly used integral type (8-bit signed integers) would require more than 700 bits, so no reasonable specification of a factorial function using fixed-size types can avoid questions of overflow. The values 12! and 20! are the largest factorials that can be stored in, respectively, the 32 bit and 64 bit integers commonly used in personal computers. Although floating point
Floating point
In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...

 representation of the result allows going a bit further, it remains quite limited by possible overflow. The largest factorial that most calculators can handle is 69!, because 69! < 10100 < 70!. Calculators that use 3-digit exponents can compute larger factorials, up to, for example, 253! ≈ 5.2 on HP
Hewlett-Packard
Hewlett-Packard Company or HP is an American multinational information technology corporation headquartered in Palo Alto, California, USA that provides products, technologies, softwares, solutions and services to consumers, small- and medium-sized businesses and large enterprises, including...

 calculators and 449! ≈ 3.9 on the TI-86
TI-86
The TI-86 is a programmable graphing calculator introduced in 1997 and produced by Texas Instruments. The TI-86 uses the Zilog Z80 microprocessor. It is partially backwards-compatible with its predecessor, the TI-85....

. The calculator seen in Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, Microsoft Excel
Microsoft Excel
Microsoft Excel is a proprietary commercial spreadsheet application written and distributed by Microsoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications...

 and Google Calculator, as well as the freeware Fox Calculator, can handle factorials up to 170!, which is the largest factorial that can be represented as a 64-bit IEEE 754 floating-point value. The scientific calculator in Windows XP is able to calculate factorials up to at least 100000!. Most software applications will compute small factorials by direct multiplication or table lookup. Larger factorial values can be approximated using Stirling's formula.

Wolfram Alpha
Wolfram Alpha
Wolfram Alpha is an answer-engine developed by Wolfram Research. It is an online service that answers factual queries directly by computing the answer from structured data, rather than providing a list of documents or web pages that might contain the answer as a search engine might...

 can calculate exact results for the ceiling function and floor function
Floor function
In mathematics and computer science, the floor and ceiling functions map a real number to the largest previous or the smallest following integer, respectively...

 applied to the binary
Binary logarithm
In mathematics, the binary logarithm is the logarithm to the base 2. It is the inverse function of n ↦ 2n. The binary logarithm of n is the power to which the number 2 must be raised to obtain the value n. This makes the binary logarithm useful for anything involving powers of 2,...

, natural
Natural logarithm
The natural logarithm is the logarithm to the base e, where e is an irrational and transcendental constant approximately equal to 2.718281828...

 and common logarithm
Common logarithm
The common logarithm is the logarithm with base 10. It is also known as the decadic logarithm, named after its base. It is indicated by log10, or sometimes Log with a capital L...

 of n! for values of n up to 249999, and up to 20,000,000! for the Integers.

If very large exact factorials are needed, they can be computed using bignum arithmetic. In such computations speed may be gained by not sequentially multiplying the numbers up to (or down from) n into a single accumulator, but by partitioning the sequence so that the products for each of the two parts are approximately of the same size, compute those products recursively and then multiply.

The asymptotically-best efficiency is obtained by computing n! from its prime factorization. As documented by Peter Borwein
Peter Borwein
Peter Benjamin Borwein is a Canadian mathematicianand a professor at Simon Fraser University. He is known as a co-discoverer of the Bailey-Borwein-Plouffe algorithm for computing π.-First interest in mathematics:...

, prime factorization allows n! to be computed in time O
Big O notation
In mathematics, big O notation is used to describe the limiting behavior of a function when the argument tends towards a particular value or infinity, usually in terms of simpler functions. It is a member of a larger family of notations that is called Landau notation, Bachmann-Landau notation, or...

(n(log n log log n)2), provided that a fast multiplication algorithm
Multiplication algorithm
A multiplication algorithm is an algorithm to multiply two numbers. Depending on the size of the numbers, different algorithms are in use...

 is used (for example, the Schönhage–Strassen algorithm). Peter Luschny presents source code and benchmarks for several efficient factorial algorithms, with or without the use of a prime sieve.

The Gamma and Pi functions

Besides nonnegative integers, the factorial function can also be defined for non-integer values, but this requires more advanced tools from mathematical analysis
Mathematical analysis
Mathematical analysis, which mathematicians refer to simply as analysis, has its beginnings in the rigorous formulation of infinitesimal calculus. It is a branch of pure mathematics that includes the theories of differentiation, integration and measure, limits, infinite series, and analytic functions...

. One function that "fills in" the values of the factorial (but with a shift of 1 in the argument) is called the Gamma function
Gamma function
In mathematics, the gamma function is an extension of the factorial function, with its argument shifted down by 1, to real and complex numbers...

, denoted Γ(z), defined for all complex numbers z except the non-positive integers, and given when the real part of z is positive by


Its relation to the factorials is that for any natural number n

Euler's
Leonhard Euler
Leonhard Euler was a pioneering Swiss mathematician and physicist. He made important discoveries in fields as diverse as infinitesimal calculus and graph theory. He also introduced much of the modern mathematical terminology and notation, particularly for mathematical analysis, such as the notion...

 original formula for the Gamma function was


It is worth mentioning that there is an alternative notation that was originally introduced by Gauss
Carl Friedrich Gauss
Johann Carl Friedrich Gauss was a German mathematician and scientist who contributed significantly to many fields, including number theory, statistics, analysis, differential geometry, geodesy, geophysics, electrostatics, astronomy and optics.Sometimes referred to as the Princeps mathematicorum...

 which is sometimes used. The Pi function, denoted Π(z) for real numbers z no less than 0, is defined by


In terms of the Gamma function it is


It truly extends the factorial in that


In addition to this, the Pi function satisfies the same recurrence as factorials do, but at every complex value z where it is defined


In fact, this is no longer a recurrence relation but a functional equation
Functional equation
In mathematics, a functional equation is any equation that specifies a function in implicit form.Often, the equation relates the value of a function at some point with its values at other points. For instance, properties of functions can be determined by considering the types of functional...

.
Expressed in terms of the Gamma function this functional equation takes the form


Since the factorial is extended by the Pi function, for every complex value z where it is defined, we can write:


The values of these functions at half-integer
Half-integer
In mathematics, a half-integer is a number of the formn + 1/2,where n is an integer. For example,are all half-integers. Note that a half of an integer is not always a half-integer: half of an even integer is an integer but not a half-integer...

 values is therefore determined by a single one of them; one has


from which it follows that for n ∈ N,


For example,

It also follows that for n ∈ N,


For example,

The Pi function is certainly not the only way to extend factorials to a function defined at almost all complex values, and not even the only one that is analytic
Analytic function
In mathematics, an analytic function is a function that is locally given by a convergent power series. There exist both real analytic functions and complex analytic functions, categories that are similar in some ways, but different in others...

 wherever it is defined. Nonetheless it is usually considered the most natural way to extend the values of the factorials to a complex function. For instance, the Bohr–Mollerup theorem states that the Gamma function is the only function that takes the value 1 at 1, satisfies the functional equation Γ(n + 1) = nΓ(n), is meromorphic on the complex numbers, and is log-convex on the positive real axis. A similar statement holds for the Pi function as well, using the Π(n) = nΠ(n − 1) functional equation.

However, there exist complex functions that are probably simpler in the sense of analytic function theory and which interpolate the factorial values. For example, Hadamard's
Jacques Hadamard
Jacques Salomon Hadamard FRS was a French mathematician who made major contributions in number theory, complex function theory, differential geometry and partial differential equations.-Biography:...

 'Gamma'-function which, unlike the Gamma function, is an entire function
Entire function
In complex analysis, an entire function, also called an integral function, is a complex-valued function that is holomorphic over the whole complex plane...

.

Euler also developed a convergent product approximation for the non-integer factorials, which can be seen to be equivalent to the formula for the Gamma function above:


However, this formula does not provide a practical means of computing the Pi or Gamma function, as its rate of convergence is slow.

Applications of the Gamma function

The volume
Volume
Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance or shape occupies or contains....

 of an n-dimensional
Dimension
In physics and mathematics, the dimension of a space or object is informally defined as the minimum number of coordinates needed to specify any point within it. Thus a line has a dimension of one because only one coordinate is needed to specify a point on it...

 hypersphere of radius R is

Factorial at the complex plane

Representation through the Gamma-function allows evaluation of factorial of complex argument. Equilines of amplitude and phase of factorial are shown in figure. Let . Several levels of constant modulus (amplitude) and constant phase are shown. The grid covers range
,

with unit step. The scratched line shows the level .

Thin lines show intermediate levels of constant modulus and constant phase. At poles , phase and amplitude are not defined. Equilines are dense in vicinity of singularities along negative integer values of the argument.

For , the Taylor expansions can be used:
The first coefficients of this expansion are































approximation
0
1
2
3


where is the Euler constant
Euler–Mascheroni constant
The Euler–Mascheroni constant is a mathematical constant recurring in analysis and number theory, usually denoted by the lowercase Greek letter ....

 and is the Riemann zeta function. Computer algebra system
Computer algebra system
A computer algebra system is a software program that facilitates symbolic mathematics. The core functionality of a CAS is manipulation of mathematical expressions in symbolic form.-Symbolic manipulations:...

s such as Sage (mathematics software) can generate many terms of this expansion.

Approximations of factorial

For the large values of the argument,
factorial can be approximated through the integral of the
digamma function, using the continued fraction
Continued fraction
In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer part and another reciprocal, and so on...

 representation.
This approach is due to T. J. Stieltjes (1894). Writing z! = exp(P(z)) where P(z) is

Stieltjes gave a continued fraction for p(z)

The first few coefficients an are
style="margin-left:2em; background:#fff; border:1px #aaa solid; border-collapse:collapse;">








nan
01 / 12
11 / 30
253 / 210
3195 / 371
422999 / 22737
529944523 / 19773142
6109535241009 / 48264275462


There is common misconception, that or
for any complex z ≠ 0. Indeed, the relation through the logarithm is valid only for specific range of values of z in vicinity of the real axis, while . The larger is the real part of the argument, the smaller should be the imaginary part. However, the inverse relation, z! = exp(P(z)), is valid for the whole complex plane apart from zero. The convergence is poor in vicinity of the negative part of the real axis. (It is difficult to have good convergence of any approximation in vicinity of the singularities). While or , the 6 coefficients above are sufficient for the evaluation of the factorial with the complex precision. For higher precision more coefficients can be computed by a rational QD-scheme (H. Rutishauser's QD algorithm).

Non-extendability to negative integers

The relation n ! = (n − 1)! × n allows one to compute the factorial for an integer given the factorial for a smaller integer. The relation can be inverted so that one can compute the factorial for an integer given the factorial for a larger integer:


Note, however, that this recursion does not permit us to compute the factorial of a negative integer; use of the formula to compute (−1)! would require a division by zero, and thus blocks us from computing a factorial value for every negative integer. (Similarly, the Gamma function is not defined for non-positive integers, though it is defined for all other complex numbers.)

Factorial-like products and functions

There are several other integer sequences similar to the factorial that are used in mathematics:

Primorial

The primorial
Primorial
In mathematics, and more particularly in number theory, primorial is a function from natural numbers to natural numbers similar to the factorial function, but rather than multiplying successive positive integers, only successive prime numbers are multiplied...

  is similar to the factorial, but with the product taken only over the prime number
Prime number
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2...

s.

Double factorial

The product of all odd integers up to some odd positive integer n is often called the double factorial of n (even though it only involves about half the factors of the ordinary factorial, and its value is therefore closer to the square root of the factorial). It is denoted by
n!!.

For an odd positive integer n = 2k - 1, k ≥ 1, it is
.

For example, 9!! = 1 × 3 × 5 × 7 × 9 = 945. This notation creates a notational ambiguity with the composition of the factorial function with itself (which for n > 2 gives much larger numbers than the double factorial); this may be justified by the fact that composition arises very seldom in practice, and could be denoted by (n!)! to circumvent the ambiguity. The double factorial notation is not essential; it can be expressed in terms of the ordinary factorial by
,

since the denominator equals and cancels the unwanted even factors from the numerator. The introduction of the double factorial is motivated by the fact that it occurs rather frequently in combinatorial and other settings, for instance
  • (2n − 1)!! is the number of permutation
    Permutation
    In mathematics, the notion of permutation is used with several slightly different meanings, all related to the act of permuting objects or values. Informally, a permutation of a set of objects is an arrangement of those objects into a particular order...

    s of 2n whose cycle type consists of n parts equal to 2; these are the involutions without fixed points.
  • (2n − 1)!! is the number of perfect matchings in a complete graph K(2n).
  • (2n − 5)!! is the number of unrooted binary tree
    Unrooted binary tree
    In mathematics and computer science, an unrooted binary tree is an unrooted tree in which each vertex has either one or three neighbors.-Definitions:...

    s with n labeled leaves.
  • The value is equal to (see above)


Sometimes n!! is defined for non-negative even numbers as well. One choice is a definition similar to the one for odd values


For example, with this definition, 8!! = 2 × 4 × 6 × 8 = 384
384 (number)
Three hundred [and] eighty four is an even composite positive integer.-In mathematics:The prime factors of 384 are 2 and 3.384 is* the sum of a twin prime .* the sum of six consecutive primes ....

.
However, note that this definition does not match the expression above, of the double factorial in terms of the ordinary factorial, and is also inconsistent with the extension of the definition of to complex numbers that is achieved via the Gamma function
Gamma function
In mathematics, the gamma function is an extension of the factorial function, with its argument shifted down by 1, to real and complex numbers...

 as indicated below. Also, for even numbers, the double factorial notation is hardly shorter than expressing the same value using ordinary factorials. For combinatorial interpretations (the value gives, for instance, the size of the hyperoctahedral group
Hyperoctahedral group
In mathematics, a hyperoctahedral group is an important type of group that can be realized as the group of symmetries of a hypercube or of a cross-polytope. Groups of this type are identified by a parameter n, the dimension of the hypercube....

), the latter expression can be more informative (because the factor 2n is the order of the kernel of a projection to the symmetric group
Symmetric group
In mathematics, the symmetric group Sn on a finite set of n symbols is the group whose elements are all the permutations of the n symbols, and whose group operation is the composition of such permutations, which are treated as bijective functions from the set of symbols to itself...

). Even though the formulas for the odd and even double factorials can be easily combined into


the only known interpretation for the sequence of all these numbers is somewhat artificial: the number of down-up permutations of a set of elements for which the entries in the even positions are increasing.

The sequence of double factorials for n = 1, 3, 5, 7, ... starts as
1, 3, 15, 105, 945, 10395, 135135, ....


Some identities involving double factorials are:


Alternative extension of the double factorial

Disregarding the above definition of n!! for even values of n, the double factorial for odd integers can be extended to most real and complex numbers z by noting that when z is a positive odd integer then
The expressions obtained by taking one of the above formulas for and and expressing the occurring factorials in terms of the gamma function can both be seen (using the multiplication theorem) to be equivalent to the one given here.

The expression found for z!! is defined for all complex numbers except the negative even numbers. Using it as the definition, the volume
Volume
Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance or shape occupies or contains....

 of an n-dimension
Dimension
In physics and mathematics, the dimension of a space or object is informally defined as the minimum number of coordinates needed to specify any point within it. Thus a line has a dimension of one because only one coordinate is needed to specify a point on it...

al hypersphere
Hypersphere
In mathematics, an n-sphere is a generalization of the surface of an ordinary sphere to arbitrary dimension. For any natural number n, an n-sphere of radius r is defined as the set of points in -dimensional Euclidean space which are at distance r from a central point, where the radius r may be any...

 of radius R can be expressed as

Multifactorials

A common related notation is to use multiple exclamation points to denote a multifactorial, the product of integers in steps of two (), three (), or more. The double factorial is the most commonly used variant, but one can similarly define the triple factorial () and so on. One can define the k-th factorial, denoted by , recursively for non-negative integers as

though see the alternative definition below.

Some mathematicians have suggested an alternative notation of for the double factorial and similarly for other multifactorials, but this has not come into general use.

With the above definition,

In the same way that is not defined for negative integers, and is not defined for negative even integers, is not defined for negative integers evenly divisible by .

Alternative extension of the multifactorial

Alternatively, the multifactorial z!(k) can be extended to most real and complex numbers z by noting that when z is one more than a positive multiple of k then
This last expression is defined much more broadly than the original; with this definition, z!(k) is defined for all complex numbers except the negative real numbers evenly divisible by k. This definition is consistent with the earlier definition only for those integers z satisfying z ≡ 1 mod k.

In addition to extending z!(k) to most complex numbers z, this definition has the feature of working for all positive real values of k. Furthermore, when k = 1, this definition is mathematically equivalent to the Π(z) function, described above. Also, when k = 2, this definition is mathematically equivalent to the alternative extension of the double factorial, described above.

Quadruple factorial

The so-called quadruple factorial, however, is not the multifactorial n!(4); it is a much larger number given by (2n)!/n!, starting as
1, 2, 12, 120, 1680, 30240, 665280, ... .


It is also equal to

Superfactorial

Neil Sloane
Neil Sloane
Neil James Alexander Sloane is a British-U.S. mathematician. His major contributions are in the fields of combinatorics, error-correcting codes, and sphere packing...

 and Simon Plouffe
Simon Plouffe
Simon Plouffe is a Quebec mathematician born on June 11, 1956 in Saint-Jovite, Quebec. He discovered the formula for the BBP algorithm which permits the computation of the nth binary digit of π, in 1995...

 defined a superfactorial in The Encyclopedia of Integer Sequences (Academic Press, 1995) to be the product of the first factorials. So the superfactorial of 4 is


In general


Equivalently, the superfactorial is given by the formula
which is the determinant
Determinant
In linear algebra, the determinant is a value associated with a square matrix. It can be computed from the entries of the matrix by a specific arithmetic expression, while other ways to determine its value exist as well...

 of a Vandermonde matrix.

The sequence of superfactorials starts (from ) as
1, 1, 2, 12, 288, 34560, 24883200, ...

Alternative definition

Clifford Pickover in his 1995 book Keys to Infinity used a new notation, n$, to define the superfactorial
or as,
where the (4) notation denotes the hyper4
Tetration
In mathematics, tetration is an iterated exponential and is the next hyper operator after exponentiation. The word tetration was coined by English mathematician Reuben Louis Goodstein from tetra- and iteration. Tetration is used for the notation of very large numbers...

 operator, or using Knuth's up-arrow notation
Knuth's up-arrow notation
In mathematics, Knuth's up-arrow notation is a method of notation for very large integers, introduced by Donald Knuth in 1976. It is closely related to the Ackermann function and especially to the hyperoperation sequence. The idea is based on the fact that multiplication can be viewed as iterated...

,
This sequence of superfactorials starts:
Here, as is usual for compound exponentiation
Exponentiation
Exponentiation is a mathematical operation, written as an, involving two numbers, the base a and the exponent n...

, the grouping is understood to be from right to left:

Hyperfactorial

Occasionally the hyperfactorial of n is considered. It is written as H(n) and defined by


For n = 1, 2, 3, 4, ... the values H(n) are 1, 4, 108, 27648,... .

The asymptotic growth rate is


where A = 1.2824... is the Glaisher–Kinkelin constant. H(14) = 1.8474...×1099 is already almost equal to a googol
Googol
A googol is the large number 10100, that is, the digit 1 followed by 100 zeros:The term was coined in 1938 by 9-year-old Milton Sirotta , nephew of American mathematician Edward Kasner...

, and H(15) = 8.0896...×10116 is almost of the same magnitude as the Shannon number
Shannon number
The Shannon number, named after Claude Shannon, is an estimated lower bound on the game-tree complexity of chess. Shannon calculated it as an aside in his 1950 paper "Programming a Computer for Playing Chess"...

, the theoretical number of possible chess games. Compared to the Pickover definition of the superfactorial, the hyperfactorial grows relatively slowly.

The hyperfactorial function can be generalized to complex number
Complex number
A complex number is a number consisting of a real part and an imaginary part. Complex numbers extend the idea of the one-dimensional number line to the two-dimensional complex plane by using the number line for the real part and adding a vertical axis to plot the imaginary part...

s in a similar way as the factorial function. The resulting function is called the K-function
K-function
In mathematics, the K-function, typically denoted K, is a generalization of the hyperfactorial to complex numbers, similar to the generalization of the factorial to the Gamma function.Formally, the K-function is defined as...

.

See also

  • Alternating factorial
    Alternating factorial
    In mathematics, an alternating factorial is the absolute value of the alternating sum of the first n factorials.This is the same as their sum, with the odd-indexed factorials multiplied by −1 if n is even, and the even-indexed factorials multiplied by −1 if n is odd, resulting in an...

  • Digamma function
  • Exponential factorial
    Exponential factorial
    An exponential factorial is a positive integer n raised to the power of n − 1, which in turn is raised to the power of n − 2, and so on and so forth, that is,...

  • Factorial number system
  • Factorial prime
    Factorial prime
    A factorial prime is a prime number that is one less or one more than a factorial . The first few factorial primes are:n! − 1 is prime for :n! + 1 is prime for :...

  • Factorion
    Factorion
    A factorion is a natural number that equals the sum of the factorials of its decimal digits. For example, 145 is a factorion because 1! + 4! + 5! = 1 + 24 + 120 = 145.There are just four factorions and they are 1, 2, 145 and 40585 .-Upper bound:...

  • Gamma function
    Gamma function
    In mathematics, the gamma function is an extension of the factorial function, with its argument shifted down by 1, to real and complex numbers...

  • List of factorial and binomial topics
  • Pochhammer symbol
    Pochhammer symbol
    In mathematics, the Pochhammer symbol introduced by Leo August Pochhammer is the notation ', where is a non-negative integer. Depending on the context the Pochhammer symbol may represent either the rising factorial or the falling factorial as defined below. Care needs to be taken to check which...

    , which gives the falling or rising factorial
  • Stirling's approximation
    Stirling's approximation
    In mathematics, Stirling's approximation is an approximation for large factorials. It is named after James Stirling.The formula as typically used in applications is\ln n! = n\ln n - n +O\...

  • Subfactorial
  • Trailing zeros of factorial
  • Triangular number
    Triangular number
    A triangular number or triangle number numbers the objects that can form an equilateral triangle, as in the diagram on the right. The nth triangle number is the number of dots in a triangle with n dots on a side; it is the sum of the n natural numbers from 1 to n...

    , the additive analogue of factorial


External links


Factorial calculators and algorithms
  • Factorial Calculator: instantly finds factorials up to 10^14!
  • Animated Factorial Calculator: shows factorials calculated as if by hand using common elementary school aglorithms
  • "Factorial" by Ed Pegg, Jr.
    Ed Pegg, Jr.
    Ed Pegg, Jr. is an expert on mathematical puzzles and is a self-described recreational mathematician. He creates puzzles for the Mathematical Association of America online at Ed Pegg, Jr.'s Math Games. His puzzles have also been used by Will Shortz on the puzzle segment of NPR's Weekend Edition...

     and Rob Morris, Wolfram Demonstrations Project
    Wolfram Demonstrations Project
    The Wolfram Demonstrations Project is hosted by Wolfram Research, whose stated goal is to bring computational exploration to the widest possible audience. It consists of an organized, open-source collection of small interactive programs called Demonstrations, which are meant to visually and...

    , 2007.
  • Fast Factorial Functions (with source code in Java, C#, C++, Scala and Go)
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK