Combination & Permutation Calculator
Calculate P(n,r), C(n,r), and repetition variants — with real-world lottery and password context.
Parameters
n = 10, r = 3
n! = 3,628,800
r! = 6
(n−r)! = 5,040
Results
Permutation P(n,r)
Order matters, no repetition
n! / (n−r)!
720
Combination C(n,r)
Order doesn't matter, no repetition
n! / (r! × (n−r)!)
120
Permutation with Repetition
Order matters, repetition allowed
nʳ
1,000
Combination with Repetition
Order doesn't matter, repetition allowed
C(n+r−1, r)
220
🎰 Lottery Odds
Choosing 3 numbers from 10: 1 in 120 chance of winning.
🔐 Password Strength
3-character passwords from 10 symbols: 1,000 possible combinations.
Comparison (values may be clipped at MAX_SAFE_INTEGER)
Combination & Permutation Calculator
Calculate permutations, combinations, and their repetition variants using factorial-based formulas with BigInt precision.
Guide
How it works
Order Matters vs. Doesn't Matter
The fundamental question in counting is whether arrangement matters. Permutations count ordered arrangements: choosing a gold, silver, and bronze medalist from 10 athletes is P(10,3) = 720 — because "Alice, Bob, Carol" and "Bob, Alice, Carol" are different outcomes. Combinations count unordered selections: choosing 3 committee members from 10 is C(10,3) = 120 — "Alice, Bob, Carol" is the same committee regardless of who's listed first. Permutations are always greater than or equal to combinations for the same n and r, since P(n,r) = C(n,r) × r!.
Factorials and Pascal's Triangle
The factorial n! = n × (n−1) × ... × 2 × 1 grows extremely fast: 10! = 3,628,800 and 20! ≈ 2.4 × 10¹⁸. This calculator uses JavaScript's BigInt for exact integer arithmetic, avoiding floating-point overflow. The binomial coefficients C(n,r) form Pascal's triangle, where each entry is the sum of the two entries above it. Row n of Pascal's triangle lists C(n,0), C(n,1), ..., C(n,n). They also appear as coefficients in the binomial expansion (a+b)ⁿ.
The Birthday Paradox
How many people do you need in a room for a 50% chance that two share a birthday? The answer is surprisingly small: just 23 people. With 70 people, the probability exceeds 99.9%. This is because we're counting pairs — 23 people generate C(23,2) = 253 pairs, and each pair has a 1/365 chance of sharing a birthday. The probability accumulates rapidly across all pairs. This paradox is exploited in cryptographic hash collision attacks.
Password Security
An 8-character password using 62 characters (a-z, A-Z, 0-9) has 62⁸ = 218,340,105,584,896 (about 218 trillion) possible combinations. At 1 billion guesses per second, cracking it takes ~2.5 days. A 12-character password from the same set has 62¹² ≈ 3.2 × 10²¹ — about 100 million years to crack. Adding symbols (95 characters total) makes 95¹² ≈ 5.4 × 10²³, raising the bar dramatically. This is why length matters more than complexity.
DNA and Genetic Diversity
DNA uses 4 nucleotides (A, T, G, C). Three-nucleotide codons encode amino acids: 4³ = 64 possible codons, but only 20 amino acids are needed — hence some amino acids have multiple codons (redundancy). The human genome has ~3 billion base pairs. The number of possible human genomes exceeds atoms in the observable universe — explaining why every person (except identical twins) is genetically unique.
Machine Learning: Hyperparameter Search
When training an ML model, tuning hyperparameters involves combinatorial explosion. Testing 5 learning rates × 4 batch sizes × 3 network depths × 6 regularization values = 360 combinations. With 10 hyperparameters each at 5 values: 5¹⁰ ≈ 10 million combinations — too many for exhaustive search. This motivates random search, Bayesian optimization, and AutoML, all rooted in combinatorics.
What is the difference between a combination and a permutation?expand_more
A permutation is an ordered selection — the sequence matters. A combination is an unordered selection — only which items are chosen matters. Example: PIN codes are permutations (1234 ≠ 4321); lottery tickets are combinations (the numbers in any order win). Always ask: 'Does changing the order give a different outcome?'
What does 'with repetition' mean?expand_more
With repetition means items can be chosen more than once. A PIN can use '1111' (repetition allowed); a race podium cannot have the same person twice (no repetition). Permutations with repetition = nʳ; combinations with repetition = C(n+r−1, r), also called 'multiset coefficients.'
How do I know which formula to use?expand_more
Ask two questions: (1) Does order matter? If yes → permutation; if no → combination. (2) Can items repeat? Use the repetition variant if yes. For racing positions → P(n,r) no repeat. For ice cream scoops (same flavor twice) → combination with repetition. For PIN codes → permutation with repetition.
Why is C(n,0) = 1 for any n?expand_more
There is exactly one way to choose 0 items from any set: choose nothing. The formula confirms this: C(n,0) = n! / (0! × n!) = n! / (1 × n!) = 1. The convention that 0! = 1 is what makes this work — and it's consistent with the recursive property that n! = n × (n−1)!.
What are the poker hand probabilities?expand_more
A 52-card deck has C(52,5) = 2,598,960 possible 5-card hands. Royal flush: 4 (probability 0.000154%). Straight flush: 36. Four of a kind: 624. Full house: 3,744. Flush: 5,108. Straight: 10,200. Three of a kind: 54,912. Two pair: 123,552. One pair: 1,098,240. High card only: 1,302,540.