Combinatorics
How To Calculate The Factorial
A factorial answers a counting question: in how many orders can a set of distinct objects be arranged? The answer is the product of every positive integer up to n, written n!, and this calculator multiplies six visible factors so nothing is hidden. With the factors 1, 2, 3, 4, 5 and 6 the product is 720, while stopping at five gives 120 and stopping at four gives 24.
Last updated
Quick Answer
n! = 1 x 2 x 3 x ... x n
- n
- The non-negative integer whose factorial is wanted
- n!
- The product of all positive integers up to n
- 0!
- The empty product, defined as 1
Multiply the integers from 1 up to n inclusive. The six-factor calculator shows the product through four as 24, through five as 120 and through all six as 720, with the ratio 6! / 5! equal to 6. By convention 0! is defined as 1.
What Is The Factorial?
The factorial of a positive integer n, written n!, is the product of all positive integers from 1 up to n. Reading 6! aloud gives six factorial, and evaluating it means multiplying 1 x 2 x 3 x 4 x 5 x 6 to reach 720. The same sequence produced step by step gives 1, then 2, then 6, then 24, then 120 and finally 720. The last multiplication before the answer is always by n itself, which is why 6! is exactly six times 5!. Factorials are defined only for non-negative integers in elementary arithmetic.
Zero factorial is defined as 1, and this convention often surprises people who expect an answer of zero. The reason is that a product with no factors is the multiplicative identity, just as a sum with no terms is zero. The recursive rule n! = n x (n - 1)! also forces the value: putting n = 1 gives 1! = 1 x 0!, so 0! must be 1. With that definition the standard formulas for permutations and combinations keep working at the boundary. Treating 0! as zero would break formulas that are otherwise reliable.
The most direct interpretation of a factorial is counting arrangements. Six distinct objects can be ordered in 720 different ways, because there are six choices for the first position, five for the second, four for the third and so on down to one. Multiply those choices and you recover 6! = 720. The same reasoning explains why a race with six competitors has 720 possible finishing orders if ties are impossible. Whenever a problem asks for the number of orderings of a whole set, the answer is a factorial.
Factorials grow extremely fast, far faster than powers with a fixed base. Ten factorial is 3,628,800, while twenty factorial is about 2.43 x 10^18, a number larger than the estimated number of grains of sand on a small beach. Each new factor multiplies the previous total by an integer that keeps increasing, so the growth accelerates. This is why software eventually overflows even with floating point storage, typically around 170! for double precision. For larger arguments one works with logarithms or an approximation rather than the exact integer.
The ratio between consecutive factorials is especially simple. Dividing 6! by 5! cancels every factor except the final 6, so the answer is 6. In general n! / (n - 1)! = n, which is just the recursive definition rearranged. This identity is used constantly when simplifying permutation and combination expressions. It also gives a quick check on any factorial calculation: the last step must multiply by n, not add it.
This calculator exposes all six factors instead of hiding them behind a single integer field. With the default factors 1, 2, 3, 4, 5 and 6 the running products are 24 after four factors, 120 after five and 720 after six. Change the sixth factor to 1 and the total becomes 120, the same as 5!, because multiplying by 1 changes nothing. Change the fifth and sixth factors to 1 and the total becomes 24, matching 4!. These variants make the structure of the product visible and help check that no factor has been skipped.
Factorials also underpin combinations, where order does not matter. The number of ways to choose k objects from n is n! divided by k! times (n - k)!, which removes the orderings that would otherwise be counted separately. For permutations, where order does matter, the denominator is dropped. In both cases the factorial supplies the raw count of arrangements before any correction. Confusing the two is the most common error in elementary counting problems.
The continuous extension of the factorial is the gamma function. It satisfies the identity Γ(n + 1) = n! at every positive integer, so it agrees with the familiar values while also being defined for non-integer and complex arguments. It is defined by an integral and is widely used in probability, statistics and physics. Because of that extension, expressions such as the factorial of one half have a meaning in advanced work, even though the elementary product does not. For ordinary counting problems the integer factorial remains the right tool.
One practical boundary is numerical size rather than mathematics. Exact factorials above about 20 already exceed the range of a standard 32-bit integer, and even double precision gives up near 171!. Spreadsheet and calculator results at that scale are approximations with only a handful of reliable digits. Stirling's approximation, which grows like n to the n times e to the minus n times the square root of two pi n, is the usual way to estimate very large factorials. Negative integers have no factorial under the elementary definition, and non-integers require the gamma function. Keep the six factors visible and the arithmetic stays transparent.
Formula
n! = 1 x 2 x 3 x ... x n
Formula page →Multiply every positive integer from 1 through n. The product of the first six integers is 720, and the empty product for n = 0 is defined as 1.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| n | Non-negative integer | count | The upper limit of the product; 6 in the worked case. |
| n! | Factorial of n | count | The product of all positive integers up to n. |
n! = n x (n - 1)!
Formula page →Each factorial is the previous one multiplied by n. Together with the convention 0! = 1, this defines the whole sequence.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| n | Current integer | count | The factor added at this step, 6 in the worked case. |
| (n - 1)! | Previous factorial | count | The product already accumulated, 120 before the final factor of 6. |
n! / (n - 1)! = n
Formula page →All shared factors cancel, leaving only n. Thus 6! / 5! = 720 / 120 = 6.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| n | Current integer | count | The uncancelled final factor. |
| (n - 1)! | Previous factorial | count | The product that divides out of the numerator. |
How To Calculate The Factorial
- 1
Write out the factors
List every positive integer up to the number you need. For six factorial the list is 1, 2, 3, 4, 5 and 6. Do not include zero: multiplying by zero would collapse the answer, and zero factorial is a separate convention. Writing the list first makes it easy to see whether any factor has been omitted.
- 2
Multiply in order
Work from left to right: 1 x 2 = 2, then 2 x 3 = 6, then 6 x 4 = 24, then 24 x 5 = 120 and finally 120 x 6 = 720. Keeping a running total prevents the most common arithmetic slips. Each step multiplies by the next integer, never adds it.
- 3
Record the running products
Note the totals at useful checkpoints. Through four factors the product is 24, through five it is 120 and through all six it is 720. These intermediate values are the same quantities the calculator reports as productThroughFour and productThroughFive. They also let you resume quickly if a later multiplication goes wrong.
- 4
Check the result with a ratio
Divide the final product by the one before it. Here 720 / 120 = 6, which is exactly the last factor. If the quotient is anything other than n, a factor has been duplicated or missed. This check costs one division and catches most manual errors.
- 5
Interpret the number
The answer 720 is the number of distinct orderings of six different objects, assuming no ties or repetitions. If there is nothing to arrange, use the convention 0! = 1, the empty product. State the factorial as an exact integer where possible, because rounded values hide the counting meaning.
Examples
Example 1: Factors 1, 2, 3, 4, 5 and 6
- f1
- 1
- f2
- 2
- f3
- 3
- f4
- 4
- f5
- 5
- f6
- 6
| Step | Calculation | Result |
|---|---|---|
| Product through two factors | 1 x 2 | 2 |
| Product through three factors | 2 x 3 | 6 |
| Product through four factors | 6 x 4 | 24 |
| Product through five factors | 24 x 5 | 120 |
| Final product | 120 x 6 | Multiplying all six factors gives 720, so the factorial is 720. |
Result: The factors 1, 2, 3, 4, 5 and 6 multiply to 720, so 6! = 720 and the product through five factors is 120.
Example 2: Sixth factor changed to 1
- f1
- 1
- f2
- 2
- f3
- 3
- f4
- 4
- f5
- 5
- f6
- 1
| Step | Calculation | Result |
|---|---|---|
| Product through four factors | 1 x 2 x 3 x 4 | 24 |
| Product through five factors | 24 x 5 | 120 |
| Apply the sixth factor | 120 x 1 | 120 |
| Check the ratio | 120 / 120 | 1 |
| Final product | 1 x 2 x 3 x 4 x 5 x 1 | The product of all six factors is 120, matching 5!. |
Result: With the sixth factor set to 1, the product of all six factors is 120, which is the same as 5!, and the ratio of the six-factor to five-factor products is 1.
Example 3: Fifth and sixth factors changed to 1
- f1
- 1
- f2
- 2
- f3
- 3
- f4
- 4
- f5
- 1
- f6
- 1
| Step | Calculation | Result |
|---|---|---|
| Product through three factors | 1 x 2 x 3 | 6 |
| Product through four factors | 6 x 4 | 24 |
| Apply the fifth factor | 24 x 1 | 24 |
| Apply the sixth factor | 24 x 1 | 24 |
| Final product | 1 x 2 x 3 x 4 x 1 x 1 | The product of all six factors is 24, matching 4!. |
Result: With the fifth and sixth factors set to 1, the product stays at 24, which matches 4!, and the product through four factors is also 24.
Calculator
Factorial (six factors)
720
- Product through five factors
- 120
- Product through four factors
- 24
- Ratio of six-factor to five-factor products
- 6
Values update as you type. This calculator covers the single scenario its formula assumes — see Common Mistakes for what it leaves out.
Prefer a full-width tool? Open the The Factorial calculator page.
Common Mistakes
Assuming 0! is zero
Zero factorial is 1 by convention, because an empty product is the multiplicative identity. Many counting formulas depend on this value at their boundary. If you substitute zero, expressions such as the number of ways to choose all objects from a set collapse to the wrong answer.
Including zero in the product
The factorial of n multiplies the positive integers 1 through n, never zero. Adding a zero factor would force the entire product to vanish. The only place zero appears is the separate convention for 0!, which stands for taking no factors at all.
Confusing permutations with combinations
A factorial counts ordered arrangements, so 6! = 720 orderings of six distinct objects. If order does not matter, most of those arrangements are the same choice and must be divided out by k!. Check whether swapping two objects creates a genuinely different outcome before choosing the formula.
Underestimating how fast factorials grow
Each step multiplies by a larger integer, so the totals accelerate: 24, 120, 720 and then 5,040. Ten factorial is already 3,628,800, and twenty factorial is around 2.43 x 10^18. A result that looks too small is usually the sign of a skipped factor.
Forgetting the last factor
It is easy to stop at five factors and report 120 when the question asks for 6! = 720. The ratio check fixes this immediately: 720 / 120 is 6, but 120 / 120 is only 1. Always confirm that the final multiplication used n itself.
Trusting huge factorials in a spreadsheet
Twenty factorial already exceeds a 32-bit integer, and double precision storage fails near 171!. Beyond that range the displayed digits are approximate. Use logarithms or Stirling's approximation for very large arguments rather than assuming the printed integer is exact.
FAQ
What is a factorial?
The factorial of a non-negative integer n is the product of all positive integers up to n. For example, 6! = 1 x 2 x 3 x 4 x 5 x 6 = 720. It counts the number of ways to arrange n distinct objects in order and is written with an exclamation mark.
Why is 0! equal to 1 rather than 0?
An empty product is defined as the multiplicative identity, which is 1. The recursive rule also requires it: 1! = 1 x 0!, so 0! must be 1. This keeps permutation and combination formulas working correctly when nothing is being arranged.
How many orderings does 6! represent?
Six distinct objects can be arranged in 720 different orders. There are six choices for the first position, five for the second, four for the third and so on, and multiplying those choices gives 720. Ties and repeated objects would change the count.
What is 6! divided by 5!?
It is 6. Since 6! = 720 and 5! = 120, dividing gives 6. More generally n! / (n - 1)! = n, because every factor except the final n cancels between numerator and denominator.
Can a factorial be calculated for a non-integer?
Not with the elementary product definition, which requires a non-negative integer. The gamma function extends the idea to non-integer and complex arguments and satisfies Γ(n + 1) = n! at every positive integer. That extension is used in advanced statistics and physics.
Why do factorials get so large so quickly?
Each new value is the previous one multiplied by a larger integer, so the growth compounds: 24, 120, 720, 5,040 and onward. Ten factorial is 3,628,800 and twenty factorial is about 2.43 x 10^18. Even computers run out of exact integer range relatively early.
References
- [1]Wikipedia, Factorial — https://en.wikipedia.org/wiki/Factorial
- [2]Wikipedia, Combination — https://en.wikipedia.org/wiki/Combination
- [3]Wikipedia, Gamma function — https://en.wikipedia.org/wiki/Gamma_function
