How to Calculate Factorials, Permutations and Combinations
Updated: October 31, 2026 · AracMerkezi
▶ Open Factorial, Permutation and Combination Calculator
Factorials, permutations and combinations are the three building blocks of counting. Questions such as "How many different orders are there?" or "How many different groups can be chosen?" are answered with these three ideas. In this guide you will find the formulas, worked step-by-step examples and the points to watch for with large numbers. To try your own numbers, use the Factorial, Permutation and Combination Calculator.
What is a factorial?
For a positive integer n, n! (n factorial) is the product of all integers from 1 to n:
n! = n × (n − 1) × (n − 2) × … × 2 × 1
For example, 5! = 5 × 4 × 3 × 2 × 1 = 120 and 10! = 3,628,800. A factorial tells you how many different orders n distinct items can be arranged in. Five people can line up in 120 different ways.
### Why is 0! equal to 1?
0! is defined as 1 for three reasons: there is exactly one way to arrange nothing (doing nothing), the relation n! = n × (n−1)! stays consistent for 1! = 1 × 0! only if 0! = 1, and C(n,n) = n! ÷ (n! × 0!) = 1 comes out right only with this definition.
### How fast does the factorial grow?
| n | n! | Number of digits |
|---|---|---|
| 5 | 120 | 3 |
| 10 | 3,628,800 | 7 |
| 20 | 2,432,902,008,176,640,000 | 19 |
| 52 | about 8.0658 × 10^67 | 68 |
| 100 | about 9.3326 × 10^157 | 158 |
20! is about 2.43 quintillion and is the last factorial that fits in a 64-bit signed integer; 21! exceeds this limit. The 2^53 limit up to which JavaScript can represent integers safely is passed between 18! and 19!. That is why large factorials need arbitrary-length integer types such as BigInt.
Permutation: when order matters
The number of ways to choose r items out of n, where order matters and without repetition, is:
P(n, r) = n! ÷ (n − r)!
The logic behind the formula is this: n options for the first pick, n−1 for the second, n−2 for the third, and so on for r steps. The product n × (n−1) × … × (n−r+1) is the same as n! ÷ (n−r)!.
Example: A club of 10 people will elect a president, a secretary and a treasurer. The roles are different, so order matters.
P(10, 3) = 10 × 9 × 8 = 720
When r = n, P(n, n) = n!: five people taking five seats can do so in P(5,5) = 120 ways.
Combination: when order does not matter
If we make the same selection without regard to order, each group made of the same people has been counted r! times in different orders. To correct this, we divide the permutation count by r!:
C(n, r) = n! ÷ (r! × (n − r)!) = P(n, r) ÷ r!
Example: A committee of 3 will be chosen from the same 10 people, with no distinction of roles.
C(10, 3) = 10! ÷ (3! × 7!) = (10 × 9 × 8) ÷ (3 × 2 × 1) = 720 ÷ 6 = 120
The permutation count is 720 and the combination count is 120; the ratio between them is exactly 3! = 6.
### Handy properties of combinations
- Symmetry: C(n, r) = C(n, n−r). For example, C(10, 7) = C(10, 3) = 120. To simplify the calculation, use the smaller of r and n−r.
- Edge values: C(n, 0) = 1 and C(n, n) = 1.
- Pascal's triangle: C(n, r) = C(n−1, r−1) + C(n−1, r).
- Total: The number of all subsets of an n-element set is 2^n; that is, C(n,0) + C(n,1) + … + C(n,n) = 2^n.
Step-by-step method
- Decide whether order matters. If it does, use a permutation; if not, a combination.
- Write down n and r. n is the total number of items and r is the number chosen.
- Check for repetition. If the same item can be chosen more than once, use the formulas for repetition.
- Apply the formula. For large n, use the simplified product instead of writing out every factorial: C(52, 5) = (52 × 51 × 50 × 49 × 48) ÷ (5 × 4 × 3 × 2 × 1).
- Sanity-check the result. A combination can never be larger than the permutation.
Example (a hand of cards): Drawing 5 cards from a 52-card deck, where order does not matter, gives C(52, 5) = 2,598,960 different hands.
Example (a large combination): The number of ways to choose 6 numbers out of 49 is C(49, 6) = 13,983,816. In a draw where every group is equally likely, the probability of one specific set of 6 is 1 ÷ 13,983,816; for more on probability, see our guide to dice and coin-flip probability.
Cases with repetition
| Case | Formula | Example |
|---|---|---|
| n options for each of r positions | n^r | 4-digit PIN: 10^4 = 10,000 |
| Unordered selection, repeats allowed | C(n + r − 1, r) | 3 scoops from 5 ice cream flavors: C(7, 3) = 35 |
| Arrangements with identical items | n! ÷ (n₁! × n₂! × …) | MISSISSIPPI: 11! ÷ (1! × 4! × 4! × 2!) = 34,650 |
Identical-items example: The word ANKARA has 6 letters, and A appears three times. The number of distinct arrangements is 6! ÷ 3! = 720 ÷ 6 = 120.
Common mistakes
- Misjudging whether order matters: Choosing a committee is a combination; assigning roles is a permutation.
- Entering r > n: Without repetition, you cannot choose more than n items from n items.
- Thinking 0! equals 0: 0! = 1.
- Computing factorials the raw way: Numbers like 52! overflow a calculator; simplify first or use a BigInt-capable tool.
- Mixing up cases with and without repetition: For choices that can repeat, such as a PIN, use n^r, not P(n, r).
Checking with the calculator
When you pick the calculation type and enter n and r in our tool, you see the expansion of the operation, the permutation-versus-combination comparison and, where relevant, the digit count and the exact value. The upper limit for n and r is 1000. When you work with prime factors, the prime factorization tool is also useful.
Note on currency of information
The formulas in this guide are universal mathematics and do not change from year to year. This guide was prepared on October 31, 2026.
Summary
A factorial counts the arrangements of n items, a permutation P(n,r) = n! ÷ (n−r)! counts ordered selections, and a combination C(n,r) = n! ÷ (r! × (n−r)!) counts unordered selections. In the examples we found P(10,3) = 720, C(10,3) = 120 and C(52,5) = 2,598,960. First decide whether order matters, then choose the right formula.
Frequently asked questions
How is a factorial calculated, and why is 0! equal to 1?
n! is the product of the integers from 1 to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. 0! is defined as 1 because there is exactly one way to arrange zero items (do nothing), and this definition keeps the counting formulas consistent.
What is the difference between a permutation and a combination?
In a permutation the order of the chosen items matters; in a combination it does not. Since P(n,r) = n! ÷ (n−r)! and C(n,r) = n! ÷ (r! × (n−r)!), we have P = C × r!. For example, P(10,3) = 720 and C(10,3) = 120.
Why do factorials above 20 cause errors on a regular calculator?
21! exceeds the 64-bit signed integer limit, and 19! is already above the 2^53 limit that JavaScript can represent safely. This tool uses BigInt, so it can compute huge results such as 1000! as exact values.
Tools mentioned in this guide
More guides
- Permutation or Combination? Examples and Common Mistakes – Permutation or combination? Worked everyday examples, cases with repetition, circular arrangements and the most common mistakes to avoid.
- How to Calculate Percentages: Six Question Types, Formulas and Examples – Percentage math: percent of a number, what percent one is of another, increase and decrease, percentage points and reverse percentages, with examples.
- How to Calculate VAT: VAT-Inclusive and VAT-Exclusive Formulas and Examples – How do you separate VAT from a VAT-inclusive amount or add it to a VAT-exclusive one? Formulas, a mixed-rate invoice, rounding gaps and shortcuts.
- How to Calculate Loan Payments: Formula, Step-by-Step Example and Interest vs. Principal Split – The monthly loan payment formula, a step-by-step example, the interest-versus-principal split and how to work back to the loan amount you can afford.
- How to Calculate Age From a Date of Birth: Age in Years, Months and Days – Work out your exact age in years, months and days, step by step. Month-end and leap-day edge cases, total days lived and common mistakes.
This article is for general information only and is not legal, financial or medical advice. We are not an official institution.