Factorial Calculator
Factorial (n!)
Combinations C(n,r)
Permutations P(n,r)
Understanding Factorials, Combinations & Permutations: Complete Guide
Factorials, combinations, and permutations are fundamental concepts in mathematics and statistics. They form the backbone of probability theory, combinatorics, and are essential for solving counting problems in computer science, data analysis, and everyday decision-making. This comprehensive guide explains each concept with formulas, examples, and real-world applications.
What is a Factorial?
A factorial, denoted by n!, is the product of all positive integers from 1 to n. It represents the number of ways to arrange n distinct objects in a sequence. The factorial function grows extremely rapidly, making it one of the fastest-growing functions in mathematics.
n! = n × (n-1) × (n-2) × ... × 3 × 2 × 1
Special Case: 0! = 1 (by mathematical convention)
Factorial Examples
5! = 5 × 4 × 3 × 2 × 1 = 120
This means there are 120 different ways to arrange 5 distinct objects.
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040
Seven people can stand in a line in 5,040 different orders.
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800
There are over 3.6 million ways to arrange 10 books on a shelf!
Factorial Value Table
| n | n! | Calculation |
| 0 | 1 | By definition |
| 1 | 1 | 1 |
| 2 | 2 | 2 × 1 |
| 3 | 6 | 3 × 2 × 1 |
| 4 | 24 | 4 × 3 × 2 × 1 |
| 5 | 120 | 5 × 4 × 3 × 2 × 1 |
| 6 | 720 | 6 × 5 × 4 × 3 × 2 × 1 |
| 7 | 5,040 | 7 × 6! |
| 8 | 40,320 | 8 × 7! |
| 10 | 3,628,800 | 10 × 9! |
| 12 | 479,001,600 | 12 × 11! |
| 15 | 1,307,674,368,000 | Over 1.3 trillion |
| 20 | 2,432,902,008,176,640,000 | Over 2.4 quintillion |
Understanding Combinations C(n,r)
A combination is a selection of items from a larger set where the order does NOT matter. Combinations answer the question: "In how many ways can we choose r items from n items?" This is fundamental in probability, statistics, and scenarios like lottery odds, team selection, and committee formation.
C(n,r) = n! ÷ (r! × (n-r)!)
Also written as: nCr or "n choose r"
Key Property: C(n,r) = C(n, n-r)
Combination Examples
How many ways can you select 3 people from a group of 10?
C(10,3) = 10! ÷ (3! × 7!)
= (10 × 9 × 8) ÷ (3 × 2 × 1)
= 720 ÷ 6 = 120 ways
How many 5-card poker hands are possible from a 52-card deck?
C(52,5) = 52! ÷ (5! × 47!)
= (52 × 51 × 50 × 49 × 48) ÷ (5 × 4 × 3 × 2 × 1)
= 311,875,200 ÷ 120 = 2,598,960 hands
A pizza shop has 8 toppings. How many ways can you choose 3 toppings?
C(8,3) = 8! ÷ (3! × 5!)
= (8 × 7 × 6) ÷ (3 × 2 × 1)
= 336 ÷ 6 = 56 combinations
Common Combination Values (Pascal's Triangle)
| n \ r | 0 | 1 | 2 | 3 | 4 | 5 |
| 5 | 1 | 5 | 10 | 10 | 5 | 1 |
| 6 | 1 | 6 | 15 | 20 | 15 | 6 |
| 7 | 1 | 7 | 21 | 35 | 35 | 21 |
| 10 | 1 | 10 | 45 | 120 | 210 | 252 |
Understanding Permutations P(n,r)
A permutation is an arrangement of items where the order DOES matter. Permutations answer the question: "In how many ways can we arrange r items from n items?" This is essential for problems involving rankings, sequences, passwords, and any scenario where position matters.
P(n,r) = n! ÷ (n-r)!
Also written as: nPr or nPr
Special Case: When r = n, P(n,n) = n! (all items arranged)
Permutation Examples
10 runners in a race. How many ways can the top 3 finish (gold, silver, bronze)?
P(10,3) = 10! ÷ 7!
= 10 × 9 × 8
= 720 possible outcomes
Create a 4-digit PIN using digits 0-9 (no repetition allowed).
P(10,4) = 10! ÷ 6!
= 10 × 9 × 8 × 7
= 5,040 possible PINs
You have 8 books but only 5 slots on a shelf. How many arrangements?
P(8,5) = 8! ÷ 3!
= 8 × 7 × 6 × 5 × 4
= 6,720 arrangements
Combinations vs Permutations: Key Differences
The critical difference is whether ORDER MATTERS. This single distinction determines which formula to use and dramatically affects the result. Understanding when to use each is essential for solving counting problems correctly.
| Aspect | Combinations | Permutations |
| Order | Does NOT matter | DOES matter |
| Formula | n! ÷ (r! × (n-r)!) | n! ÷ (n-r)! |
| Result Size | Smaller (fewer outcomes) | Larger (more outcomes) |
| Relationship | P(n,r) = C(n,r) × r! | |
| Example (5,3) | C(5,3) = 10 | P(5,3) = 60 |
| Real Example | Selecting lottery numbers | Assigning race positions |
- Use Combinations when: You're selecting a group, choosing members, picking items (team selection, lottery, committee)
- Use Permutations when: Order/position matters (rankings, passwords, seating arrangements, race results)
Real-World Applications
Factorials, combinations, and permutations appear in countless real-world scenarios across various fields including probability, statistics, computer science, genetics, and everyday decision-making.
🎰 Lottery & Gambling
Calculating lottery odds uses combinations. For a 6/49 lottery: C(49,6) = 13,983,816 possible combinations, meaning your odds of winning are about 1 in 14 million.
🔐 Cybersecurity
Password strength depends on permutations. A 8-character password with 95 printable ASCII characters has 95^8 ≈ 6.6 quadrillion possible combinations.
🧬 Genetics & DNA
Genetic combinations during reproduction use these principles. The possible gene combinations from parents explain genetic diversity and inheritance patterns.
💻 Computer Science
Algorithm complexity analysis uses factorials. The traveling salesman problem has (n-1)!/2 routes, making it computationally intensive for large n.
🏆 Sports & Tournaments
Bracket predictions use combinations. March Madness has 2^63 possible bracket outcomes—more than 9 quintillion possibilities!
📊 Statistics & Probability
The binomial coefficient C(n,r) is central to probability distributions, statistical sampling, and hypothesis testing used in research and data science.
Important Properties and Identities
Understanding these mathematical properties helps simplify calculations and provides deeper insight into how these functions relate to each other.
Factorial Properties
- Recursive definition: n! = n × (n-1)!
- Zero factorial: 0! = 1 (by mathematical convention)
- Negative factorials: Undefined for negative integers
- Growth rate: Factorials grow faster than exponentials (n! > a^n for large n)
- Stirling's approximation: n! ≈ √(2πn) × (n/e)^n for large n
Combination Properties
- Symmetry: C(n,r) = C(n, n-r)
- Boundary values: C(n,0) = C(n,n) = 1
- Pascal's identity: C(n,r) = C(n-1,r-1) + C(n-1,r)
- Sum property: C(n,0) + C(n,1) + ... + C(n,n) = 2^n
- Hockey stick identity: C(r,r) + C(r+1,r) + ... + C(n,r) = C(n+1,r+1)
Permutation Properties
- Full permutation: P(n,n) = n!
- Single selection: P(n,1) = n
- Relationship to combinations: P(n,r) = C(n,r) × r!
- No selection: P(n,0) = 1
Common Mistakes to Avoid
Even experienced students make these errors. Recognizing common pitfalls helps develop accurate problem-solving habits.
Wrong: Using permutations to count committee selections
✅ Correct: Use combinations for selection, permutations for arrangement
Wrong: Assuming 0! = 0
✅ Correct: 0! = 1 by mathematical definition (needed for formulas to work)
Wrong: C(n,r) = n! ÷ r! (missing the (n-r)! term)
✅ Correct: C(n,r) = n! ÷ (r! × (n-r)!)
Wrong: Calculating C(5,7) or P(5,7)
✅ Correct: r must always be ≤ n (can't choose more items than available)
- Always ask: "Does the order of selection matter?"
- Write out the formula before plugging in numbers
- Simplify factorials by canceling common terms
- Check your answer by trying a smaller example
- Remember: Permutations always ≥ Combinations for same n and r
Practice Problems with Solutions
Test your understanding with these practice problems. Try solving them before checking the solutions.
Show Solution
6! = 6 × 5 × 4 × 3 × 2 × 1 = 720
Show Solution
This is a combination (order doesn't matter):
C(12,4) = 12! ÷ (4! × 8!) = (12×11×10×9) ÷ (4×3×2×1) = 11,880 ÷ 24 = 495 ways
Show Solution
This is P(5,5) = 5! = 5 × 4 × 3 × 2 × 1 = 120 arrangements
Show Solution
This is a permutation (positions matter):
P(8,3) = 8! ÷ 5! = 8 × 7 × 6 = 336 ways
Show Solution
This is a combination (topping order doesn't matter):
C(10,3) = 10! ÷ (3! × 7!) = (10×9×8) ÷ (3×2×1) = 720 ÷ 6 = 120 pizzas
Show Solution
8! ÷ 6! = (8 × 7 × 6!) ÷ 6! = 8 × 7 = 56
Frequently Asked Questions
Why is 0! equal to 1?
By mathematical convention, 0! = 1 because there is exactly one way to arrange zero objects (doing nothing). This also makes formulas work correctly: C(n,n) = n! ÷ (n! × 0!) = 1 only if 0! = 1.
What's the largest factorial a calculator can compute?
Most calculators overflow around 170! because the result exceeds 10^308 (the limit for floating-point numbers). Our calculator handles up to 20! accurately with exact integer arithmetic.
Can factorials be negative or fractional?
The factorial function n! is traditionally defined only for non-negative integers. However, the Gamma function Γ(n) extends factorials to all complex numbers except negative integers, where Γ(n+1) = n! for positive integers.
What's the difference between "with replacement" and "without replacement"?
Without replacement means each item can only be selected once (standard combinations/permutations). With replacement allows items to be selected multiple times, requiring different formulas: n^r for permutations with replacement, and C(n+r-1,r) for combinations with replacement.
How do I know when to use which formula?
Ask two questions: (1) Does order matter? If yes, use permutations; if no, use combinations. (2) Can items repeat? If yes, use "with replacement" formulas; if no, use standard formulas. The problem context usually makes this clear—rankings and passwords suggest permutations; selections and teams suggest combinations.