Permutation & Combination Calculator
Enter n and r, then click Calculate.
Enter n and r, then click Calculate.
How Does the Formula Work?
The permutation and combination calculator computes both P(n,r) — the number of ordered arrangements — and C(n,r) — the number of unordered selections — from n total items choosing r at a time. It also displays all intermediate factorials and a step-by-step breakdown of the calculation so you can follow the math. This is the fundamental counting tool in combinatorics, used in probability theory, statistics, computer science, cryptography, and standardized test preparation. Enter n (total items) and r (items chosen) to get instant results with full working shown.
Combination: C(n,r) = n! / (r! × (n−r)!) — order doesn't matter
Factorial: n! = n × (n−1) × (n−2) × … × 2 × 1
P(10,3) = 10×9×8 = 720 | C(10,3) = 720/6 = 120
Symmetry: C(n,r) = C(n, n−r)
Permutation vs Combination — When Order Matters
The key question is: does the order of selection matter? If yes, use permutation. If no, use combination. A lock code 1-2-3 is different from 3-2-1 — that is a permutation problem (P). A committee of 3 people from 10 candidates is the same regardless of selection order — that is a combination problem (C). Permutations are always larger than or equal to combinations because each combination corresponds to r! permutations (all the different orderings of the same group). P(10,3) = 720 while C(10,3) = 120 — exactly 720/6 where 6 = 3! is the number of ways to arrange 3 items. Memory trick: Permutation = Position matters; Combination = Committee (order irrelevant).
Common Examples
Lottery numbers are combinations — C(49,6) = 13,983,816 possible tickets for a pick-6-from-49 lottery. Poker hands are combinations — C(52,5) = 2,598,960 possible 5-card hands. Phone PIN codes are permutations — P(10,4) = 5,040 possible 4-digit PINs using digits 0-9 without repetition (with repetition: 10,000). Race finishing positions are permutations — P(8,3) = 336 possible ways to fill gold, silver, bronze from 8 runners. Password possibilities with 26 lowercase letters, 5 characters with repetition: 26⁵ = 11,881,376. Tournament brackets for 16 teams with seeded positions: 16! = over 20 trillion arrangements. DNA codons: 4 bases arranged in groups of 3 = 4³ = 64 possible codons (with repetition). These examples illustrate why counting formulas are essential — enumeration by hand is simply impossible for realistic problems.
Step-by-Step Calculation
Understanding the factorial breakdown makes these formulas intuitive. P(10,3) asks: how many ways to fill 3 ordered positions from 10 items? First position: 10 choices. Second: 9 remaining. Third: 8. Total: 10 × 9 × 8 = 720. The formula n!/(n−r)! cancels the tail: 10!/7! = (10×9×8×7!)/7! = 10×9×8. C(10,3) then divides by r! = 3! = 6 to remove duplicate orderings: 720/6 = 120. This calculator shows these steps explicitly so you can verify your understanding and present clear solutions in homework or exams. The step-by-step format is especially valuable for students learning combinatorics for the first time.
Applications in Computer Science
Combinatorics is foundational to computer science. Algorithm complexity analysis uses combinations and permutations to count operations. A brute-force password cracker testing all permutations of an 8-character password from 62 possible characters (a-z, A-Z, 0-9) faces 62⁸ ≈ 218 trillion possibilities. Hashing algorithms distribute n items into k buckets — the birthday attack exploits the birthday paradox (related to C(365,2)). Database query optimization involves choosing which indexes to use from available options — a combinatorial problem. Machine learning's feature selection from n features choosing k uses C(n,k) to count possible subsets. Network routing algorithms evaluate permutations of paths. Genome sequencing combines billions of DNA fragments — the number of possible assemblies is astronomical. Understanding these counts helps computer scientists design efficient algorithms and understand computational complexity.
Probability Connection
Combinatorics and probability are inseparable. Probability of an event = favorable outcomes / total outcomes — and counting those outcomes requires permutations and combinations. Probability of a royal flush in poker: 4 favorable hands (one per suit) out of C(52,5) = 2,598,960 total = 1 in 649,740. Probability of matching all 6 numbers in a 49-number lottery: 1/C(49,6) = 1/13,983,816 ≈ 0.00000715 percent. Probability of getting exactly 3 heads in 5 coin flips: C(5,3) × 0.5³ × 0.5² = 10 × 0.03125 = 0.3125 = 31.25 percent. This binomial probability formula C(n,k) × pᵏ × (1−p)ⁿ⁻ᵏ underpins quality control, clinical trials, and polling — all built on the combination formula this calculator computes.
Factorial Growth
Factorial numbers grow astronomically fast — this is why counting problems become impossible without formulas. 10! = 3,628,800. 15! = 1,307,674,368,000. 20! exceeds 2.4 quintillion. 52! (the number of ways to shuffle a standard deck of cards) is approximately 8 × 10⁶⁷ — a number so large that if every person on Earth shuffled a deck every second since the Big Bang, the probability of any two identical shuffles would be essentially zero. This calculator handles values up to 170! which is near the limit of JavaScript's floating-point precision. For larger values, specialized big-number libraries are required. Understanding factorial growth helps you appreciate why encryption works — the search space for even modest key lengths is computationally intractable.
Permutations and combinations are the building blocks of counting. This calculator makes these fundamental formulas instantly accessible — from homework verification to lottery odds calculation to cryptographic analysis. Enter n and r, click Calculate, and see the complete breakdown with step-by-step working.
Whether you are a student preparing for standardized tests, a data scientist designing experiments, or simply curious about how many possibilities exist in everyday scenarios — this tool transforms abstract mathematical formulas into immediate, practical answers.
Tips & Recommendations
Lock codes, rankings, race positions — order matters = permutation.
Lottery, committees, card hands — order irrelevant = combination.
P(n,r) ÷ r! = C(n,r). Permutations are always ≥ combinations.
C(n,r) = C(n, n−r). Choosing 3 from 10 = excluding 7 from 10.
Frequently Asked Questions
When do I use permutation vs combination?
Order matters = permutation (lock codes, race positions). Order doesn't matter = combination (lottery, committees).
What is factorial?
n! = n × (n−1) × … × 1. For example, 5! = 120. By convention, 0! = 1.
What is the maximum n?
170. Beyond that, n! exceeds JavaScript's number precision.
Why is C(n,r) = C(n, n−r)?
Choosing r items to include is the same as choosing n−r items to exclude. C(10,3) = C(10,7) = 120.
Can I calculate lottery odds?
Yes. Enter total numbers as n, numbers drawn as r. C(49,6) = 13,983,816 for a 6/49 lottery.
Recent Calculations
No calculations yet