Numbers & Arithmetic

Factorial (n!): Meaning, Formula and Worked Examples

The factorial of a non-negative whole number nn, written n!n!, is the product of every positive whole number from nn down to 11. For example, 5!=5×4×3×2×1=1205! = 5 \times 4 \times 3 \times 2 \times 1 = 120, and by definition 0!=10! = 1.

n!=n×(n−1)×(n−2)×⋯×2×1n! = n \times (n-1) \times (n-2) \times \cdots \times 2 \times 1

Try it with your numbers

Show every step

Read n!n! as “n factorial.” The shortcut that does most of the work in algebra is n!=n×(n−1)!n! = n \times (n-1)!, because it lets you build one factorial from the one before it and cancel factorials in fractions.

How do you calculate a factorial?

Start at nn, multiply by n−1n-1, then by n−2n-2, and keep going until you reach 11. Because the recursive rule n!=n×(n−1)!n! = n \times (n-1)! holds, you never need to restart from scratch: if you know one factorial, the next is a single multiplication.

Example 1. Find 8!8!.

8!=8×7×6×5×4×3×2×18! = 8 \times 7 \times 6 \times 5 \times 4 \times 3 \times 2 \times 1

Multiply left to right: 8×7=568 \times 7 = 56, then 56×6=33656 \times 6 = 336, then 336×5=1680336 \times 5 = 1680, then 1680×4=67201680 \times 4 = 6720, then 6720×3=201606720 \times 3 = 20160, then 20160×2=4032020160 \times 2 = 40320. So 8!=40,3208! = 40{,}320. The shortcut gives the same answer in one step: since 7!=50407! = 5040, you get 8×5040=40,3208 \times 5040 = 40{,}320.

Memorize 1!1! through 6!6! (they are 1,2,6,24,120,7201, 2, 6, 24, 120, 720) and you can rebuild everything else quickly. Pairing factors also helps by hand: 5!=(5×4)(3×2)=20×65! = (5 \times 4)(3 \times 2) = 20 \times 6, which is easier to hold in your head than a long chain.

Quick check

Given 9!=362,8809! = 362{,}880, find 10!10! without multiplying from scratch.

Why does n factorial count arrangements?

Four swapped-letter versions of LEVEL all spell the same word, so 120 divided by 4 gives 30
The 2 L's and 2 E's can be swapped in 2! × 2! = 4 ways without changing the word, so 120 ÷ 4 = 30 arrangements.

The formula is not arbitrary. Suppose you line up nn people in nn chairs. The first chair can be filled nn ways, the second chair then has n−1n-1 people left to choose from, the third has n−2n-2, and so on down to one person for the last chair. Choices at each stage multiply, which gives n×(n−1)×⋯×1n \times (n-1) \times \cdots \times 1. That is the whole reason the factorial exists, and it rests on nothing more than multiplying integers.

You can check it by listing. The letters A,B,CA, B, C can be ordered as ABC,ACB,BAC,BCA,CAB,CBAABC, ACB, BAC, BCA, CAB, CBA, which is 66 orderings, and 3!=63! = 6.

The trap here is repeated objects. The word LEVEL does not have 5!=1205! = 120 distinct arrangements, because swapping the two L’s (or the two E’s) gives the same word. Divide out each repeat:

5!2!×2!=1204=30\frac{5!}{2! \times 2!} = \frac{120}{4} = 30

Whenever identical items appear, the factorial overcounts, and you divide by the factorial of each repeat count.

Why does 0 factorial equal 1?

Run the recursive rule backward. Rearranging n!=n×(n−1)!n! = n \times (n-1)! gives (n−1)!=n!n(n-1)! = \frac{n!}{n}. Start from 4!=244! = 24:

3!=244=6,2!=63=2,1!=22=1,0!=11=13! = \frac{24}{4} = 6, \quad 2! = \frac{6}{3} = 2, \quad 1! = \frac{2}{2} = 1, \quad 0! = \frac{1}{1} = 1

The pattern forces 0!=10! = 1. It also fits the counting meaning: there is exactly one way to arrange nothing, namely the empty arrangement. The full argument is on the page about why zero factorial equals 1.

What if 0! were 0?

Then 1!=1×0!=01! = 1 \times 0! = 0, and every factorial after it would collapse to 00. Defining 0!=10! = 1 is the only choice that keeps the whole system consistent.

Students often assume 0!=00! = 0 because “nothing times anything is nothing.” That reasoning applies to a product with a factor of zero in it, but 0!0! is an empty product, and an empty product is defined as 11, the same way x0=1x^0 = 1.

How do you simplify factorial fractions and expressions?

Most factorial questions in algebra are really cancellation questions. The key idea: write the larger factorial down only as far as the smaller one, then cancel. It is the same move as reducing numbers in simplifying fractions, except the common factor is a whole factorial.

  1. Pick the smaller factorial in the fraction.
  2. Expand the larger factorial until the smaller one appears as a tail.
  3. Cancel that matching factorial from top and bottom.
  4. Multiply or expand what is left.

Example 2. Simplify 10!7! 3!\frac{10!}{7!\,3!}.

10!7! 3!=10×9×8×7!7!×3!=10×9×83×2×1=7206=120\frac{10!}{7!\,3!} = \frac{10 \times 9 \times 8 \times 7!}{7! \times 3!} = \frac{10 \times 9 \times 8}{3 \times 2 \times 1} = \frac{720}{6} = 120

Example 3. Simplify (n+2)!n!\frac{(n+2)!}{n!}.

(n+2)!n!=(n+2)(n+1) n!n!=(n+2)(n+1)=n2+3n+2\frac{(n+2)!}{n!} = \frac{(n+2)(n+1)\,n!}{n!} = (n+2)(n+1) = n^2 + 3n + 2

The common error is cancelling the exclamation mark as if it were a factor. 8!4!\frac{8!}{4!} is not 2!2!. Expand it properly: 8!4!=8×7×6×5=1680\frac{8!}{4!} = 8 \times 7 \times 6 \times 5 = 1680. Division of factorials gives a product of the numbers between, never a smaller factorial (unless the gap happens to fit).

Quick check

Simplify 10!8! 2!\frac{10!}{8!\,2!}.

Where does the factorial sign fit in the order of operations?

The factorial binds to the number directly in front of it, much like an exponent does. So it is done before multiplication, division, addition and subtraction, which matters when you apply the order of operations to mixed expressions.

2⋅3!=2⋅6=12but(2⋅3)!=6!=7202 \cdot 3! = 2 \cdot 6 = 12 \qquad \text{but} \qquad (2 \cdot 3)! = 6! = 720

3!+2!=6+2=8but(3+2)!=5!=1203! + 2! = 6 + 2 = 8 \qquad \text{but} \qquad (3+2)! = 5! = 120

Two more traps cost points. First, (n−1)!(n-1)! is not n!−1n! - 1: at n=4n = 4 the first is 3!=63! = 6 and the second is 24−1=2324 - 1 = 23. Second, a factorial does not distribute over addition or multiplication, so (a+b)!≠a!+b!(a+b)! \neq a! + b!. In general (2n)!≠2⋅n!(2n)! \neq 2 \cdot n! either. Extra practice with mixed expressions is on the order of operations practice problems page.

A symbol you may meet is the double factorial n!!n!!, which multiplies every second number: 7!!=7×5×3×1=1057!! = 7 \times 5 \times 3 \times 1 = 105. It is a different operation from (7!)!(7!)!, which would be a number with more than 15,00015{,}000 digits.

Try this: Evaluate 5!4!+2⋅3!\dfrac{5!}{4!} + 2 \cdot 3! by hand, doing each factorial before anything else. (Answer: 5+12=175 + 12 = 17.)

Can you take the factorial of a negative number or a fraction?

For negative integers, no. Try (−1)!(-1)! with the backward rule: 0!=0×(−1)!0! = 0 \times (-1)! would need 1=0×(something)1 = 0 \times (\text{something}), which is impossible. So (−1)!(-1)!, (−2)!(-2)! and the rest are undefined. Watch the sign placement, though: −3!=−(3!)=−6-3! = -(3!) = -6, while (−3)!(-3)! does not exist.

Decimals and fractions are not part of the school definition either, so a problem asking for 2.5!2.5! is usually a calculator exercise. Mathematicians do extend the idea with the gamma function, which satisfies Γ(n+1)=n!\Gamma(n+1) = n! for whole numbers and is defined by an integral:

Γ(z)=∫0∞tz−1e−t dt\Gamma(z) = \int_0^{\infty} t^{z-1} e^{-t}\,dt

This gives meaningful values between the whole numbers. For instance (12)!=Γ ⁣(32)=π2≈0.886\left(\tfrac{1}{2}\right)! = \Gamma\!\left(\tfrac{3}{2}\right) = \frac{\sqrt{\pi}}{2} \approx 0.886. It is a reminder that the factorial you use in class lives only on the whole numbers, a small corner of the real number system, and the smooth curve through those points is a separate idea.

How fast do factorials grow, and why do they end in zeros?

Grid of 1 to 100 highlighting multiples of 5 and 25 to count 24 zeros in 100 factorial
Each multiple of 5 adds one zero, and 25, 50, 75 and 100 add one more each, so 20 + 4 = 24.

Growth is the surprising part. Adding 1+2+⋯+101 + 2 + \cdots + 10 gives 5555, which you can get from the arithmetic series formula, but multiplying the same numbers gives 3,628,8003{,}628{,}800.

nn n!n!
0 1
1 1
2 2
3 6
4 24
5 120
6 720
7 5,040
8 40,320
9 362,880
10 3,628,800

By n=20n = 20 the value is about 2.43×10182.43 \times 10^{18}, which is why scientific notation takes over. Many scientific calculators overflow at 70!70!, which is about 1.2×101001.2 \times 10^{100}. For estimates, Stirling’s approximation says n!≈2πn (ne)nn! \approx \sqrt{2\pi n}\,\left(\frac{n}{e}\right)^n. At n=10n = 10 it gives about 3.603.60 million, within roughly 1%1\% of the true value.

Trailing zeros come from factors of 10=2×510 = 2 \times 5. Every even number supplies a 22, so there are always more 22s than 55s, and the number of zeros equals the number of 55s in the prime factorization of n!n!. Multiples of 2525 count twice, multiples of 125125 three times, and so on:

zeros in n!=⌊n5⌋+⌊n25⌋+⌊n125⌋+⋯\text{zeros in } n! = \left\lfloor \frac{n}{5} \right\rfloor + \left\lfloor \frac{n}{25} \right\rfloor + \left\lfloor \frac{n}{125} \right\rfloor + \cdots

For 100!100! that is 20+4=2420 + 4 = 24 zeros.

Quick check

How many zeros does 20!20! end with?

Where are factorials used in real problems?

Anywhere you count orderings. The number of ways to arrange nn distinct items is n!n!, and a standard deck has 52!≈8.07×106752! \approx 8.07 \times 10^{67} possible shuffles, so a well-shuffled deck has almost certainly never occurred before in history.

Two formulas built from factorials come up constantly. Permutations count ordered selections of rr items from nn, and combinations count unordered ones:

P(n,r)=n!(n−r)!C(n,r)=n!r! (n−r)!P(n,r) = \frac{n!}{(n-r)!} \qquad C(n,r) = \frac{n!}{r!\,(n-r)!}

Order or no order?

The combination formula is the permutation formula divided by r!r!, which removes the r!r! reorderings of each chosen group.

Example 4. Choose a podium (gold, silver, bronze) from 1010 runners, versus choosing a 33-person committee from 1010 people.

P(10,3)=10!7!=10×9×8=720C(10,3)=10!3! 7!=7206=120P(10,3) = \frac{10!}{7!} = 10 \times 9 \times 8 = 720 \qquad C(10,3) = \frac{10!}{3!\,7!} = \frac{720}{6} = 120

The ratio is exactly 3!=63! = 6, because each committee can be ordered 66 ways on a podium. Factorials also power the series for ee, since e=∑k=0∞1k!e = \sum_{k=0}^{\infty} \frac{1}{k!}. Adding the terms through 5!5! gives 1+1+0.5+0.1667+0.0417+0.0083≈2.71671 + 1 + 0.5 + 0.1667 + 0.0417 + 0.0083 \approx 2.7167, already close to 2.718282.71828.

How can you check a factorial answer?

A few quick tests catch most arithmetic slips. Use them before you trust a long product or a calculator result.

  • Divisibility: n!n! is a multiple of every whole number from 11 to nn. Spot-check with the divisibility rules: 7!=50407! = 5040 must be divisible by 77, 66, 55, and so on.
  • Last digits: for n≥5n \geq 5, n!n! ends in 00 (it contains both a 22 and a 55). For n≥2n \geq 2 it is always even.
  • Ratio test: n!(n−1)!\frac{n!}{(n-1)!} must equal nn. If your 9!9! divided by your 8!8! is not 99, one is wrong.
  • Size estimate: compare with Stirling’s formula or the table above, since a result off by a factor of 1010 is an arithmetic error.

The divisibility test works because n!n! literally has each of those numbers as a factor. It also explains why a list of multiples of numbers 1 to 100 will always include n!n! once you are looking at a multiple of any number up to nn. For algebraic answers, test with a small value: if you simplify (n+2)!n!\frac{(n+2)!}{n!} to (n+2)(n+1)(n+2)(n+1), plug in n=3n = 3 and confirm 5!3!=20=5×4\frac{5!}{3!} = 20 = 5 \times 4.

Practice problems

0 of 5 solved

  1. Evaluate 5!5!.

  2. Evaluate 8!6!\frac{8!}{6!}.

  3. Evaluate 2⋅3!+4!2 \cdot 3! + 4!.

  4. Simplify (n+3)!(n+1)!\frac{(n+3)!}{(n+1)!}.

  5. Solve (n+1)!(n−1)!=42\frac{(n+1)!}{(n-1)!} = 42 for a positive integer nn.

Common questions

What does the exclamation mark mean in math?

After a whole number it means factorial: multiply that number by every positive whole number below it. So 6!=6×5×4×3×2×1=7206! = 6 \times 5 \times 4 \times 3 \times 2 \times 1 = 720. It is read as "six factorial", not as an exclamation.

What is 0 factorial, and why is it 1?

By definition 0!=10! = 1. It is the only value that keeps n!=n×(n−1)!n! = n \times (n-1)! true at n=1n = 1, and it matches the fact that there is exactly one way to arrange zero objects.

Can you take the factorial of a negative number?

Not a negative integer: (−1)!(-1)!, (−2)!(-2)! and so on are undefined. Negative non-integers such as −12-\frac{1}{2} can be handled with the gamma function, which is beyond most algebra courses.

What is the difference between n!n! and n!!n!!?

A double factorial n!!n!! multiplies every second number down from nn, so 7!!=7×5×3×1=1057!! = 7 \times 5 \times 3 \times 1 = 105. It is not the factorial of a factorial, which would be written (n!)!(n!)!.

How many zeros are at the end of 100 factorial?

There are 24. Count factors of 5: ⌊100/5⌋+⌊100/25⌋=20+4=24\lfloor 100/5 \rfloor + \lfloor 100/25 \rfloor = 20 + 4 = 24.

Why do factorials grow so fast?

Each step multiplies by a bigger number than the last, so the multiplier keeps increasing instead of staying fixed. That is why 10!10! is already 3,628,8003{,}628{,}800 and 20!20! is about 2.43×10182.43 \times 10^{18}.

Up next