# Factorial

The factorial of a whole number $n$ , written as $n!$ or $n$ , is found by multiplying $n$ by all the whole numbers less than it. For example, the factorial of 4 is 24, because $4\times 3\times 2\times 1=24$ . Hence one can write $4!=24$ . For some technical reasons, 0! is equal to 1.

Factorials can be used to find out how many possible ways there are to arrange $n$ objects.

For example, if there are 3 letters (A, B, and C), they can be arranged as ABC, ACB, BAC, BCA, CAB, and CBA. That is be 6 choices because A can be put in 3 different places, B has 2 choices left after A is placed, and C has only one choice left after A and B are placed. In other words, $3\times 2\times 1=6$ choices.

The factorial function is a good example of recursion (doing things over and over), as $3!$ can be written as $3\times 2!$ , which can be written as $3\times 2\times 1!$ and finally as $3\times 2\times 1\times 0!$ . Because of this, $n!$ can also be defined as $n\times (n-1)!$ , with $0!=1$ The factorial function grows very fast. There are $10!=3,628,800$ ways to arrange 10 items.

## Applications

The earliest uses of the factorial function involve counting permutations: there are $n!$ different ways of arranging $n$ distinct objects into a sequence. Factorials appear more broadly in many formulas in combinatorics, to account for different orderings of objects. For instance the binomial coefficients ${\tbinom {n}{k}}$ count the $k$ -element combinations (subsets of $k$ elements) from a set with $n$ elements, and can be computed from factorials using the formula

## ${\binom {n}{k}}={\frac {n!}{k!(n-k)!}}.$ Related sequences and functions

Several other integer sequences are similar to or related to the factorials:

Alternating factorial
The alternating factorial is the absolute value of the alternating sum of the first $n$ factorials, ${\textstyle \sum _{i=1}^{n}(-1)^{n-i}i!}$ . These have mainly been studied in connection with their primality; only finitely many of them can be prime, but a complete list of primes of this form is not known.