Permutations and Combinations Calculator (nPr & nCr)
Calculate total arrangements ($n ext{P}r$) and selections ($n ext{C}r$) with exact arbitrary-precision BigInt integers, repetition modes, step-by-step factorial cancellations, and lottery probability odds.
📐 Step-by-Step Factorial Cancellation Proofs
Algebraic SimplificationDirectly expanding large factorials is computationally wasteful. Instead, $(n - r)!$ cancels completely from the numerator:
🃏 Standard 5-Card Poker Hand Combinations (52 C 5)
Total Hands = 2,598,960Combinatorics gives exact counts and probabilities for every poker hand in a standard 52-card deck:
| Poker Hand | Combinatorics Formula | Total Possible Hands | Exact Odds |
|---|---|---|---|
| Royal Flush | 4 suits × 1 | 4 | 1 in 649,740 |
| Straight Flush | (10 - 1) × 4 | 36 | 1 in 72,193 |
| Four of a Kind | 13 × (48 C 1) | 624 | 1 in 4,165 |
| Full House | (13 C 1)(4 C 3) × (12 C 1)(4 C 2) | 3,744 | 1 in 694 |
| Flush | 4 × (13 C 5) - 40 | 5,108 | 1 in 509 |
| Straight | 10 × (4^5) - 40 | 10,200 | 1 in 255 |
| Three of a Kind | 13 × (4 C 3) × (12 C 2) × 4^2 | 54,912 | 1 in 47 |
| Two Pair | (13 C 2)(4 C 2)^2 × (11 C 1)(4 C 1) | 123,552 | 1 in 21 |
| One Pair | 13 × (4 C 2) × (12 C 3) × 4^3 | 1,098,240 | 1 in 2.37 (42.26%) |
| High Card | [(13 C 5) - 10] × (4^5 - 4) | 1,302,540 | 1 in 2 (50.12%) |
⚠️ 5 Critical Combinatorics Traps & Common Fallacies
🔐 1. The "Combination Lock" Semantic Misnomer (Order Matters)
A standard rotary dial lock is mathematically a permutation lock, because order strictly matters. Dialing 30-10-20 will not open a mechanism set to 10-20-30. True combinations exist only when item order is completely irrelevant, such as selecting a 5-card poker hand or lottery balls from a hopper.
🔄 2. The Duplicate Items Overcounting Fallacy (Multinomial Permutations)
When calculating arrangements of collections with repeated elements (e.g. anagrams of the word "MISSISSIPPI"), standard $n!$ drastically overcounts identical permutations. You must divide by the factorials of each repeated element: $11! / (4! imes 4! imes 2!) = 34,650$, rather than the naive $11! = 39,916,800$.
🎲 3. Sampling With vs. Without Replacement Confusion
Drawing cards from a deck without replacement depletes the candidate pool on each draw ($52 o 51 o 50$, evaluating as $nPr$). Conversely, rolling dice, flipping coins, or brute-forcing alphanumeric passwords samples with replacement, meaning trials are independent and possibilities compound exponentially ($n^r$). Mixing up these sampling paradigms completely invalidates probability calculations.
🃏 4. Stars and Bars Partitioning in Combinations with Repetition
Selecting $r$ items from $n$ types where repetition is allowed (such as choosing 6 donuts from 4 varieties) cannot be solved with naive addition. It requires the "stars and bars" combinatorial theorem: $C(n + r - 1, r) = rac{(n+r-1)!}{r!(n-1)!}$. For 6 donuts from 4 types, this yields $C(4+6-1, 6) = C(9, 6) = 84$ distinct assortments.
🧮 5. Factorial Explosions & 64-Bit Integer Precision Overflow
Factorials grow faster than exponential functions: $10! = 3.62 imes 10^6$, but $20! = 2.43 imes 10^{18}$, exceeding the JavaScript IEEE 754 safe integer limit ($ ext{MAX_SAFE_INTEGER} = 2^{53} - 1 approx 9.007 imes 10^{15}$). Calculating permutations of $n ge 18$ using standard integers introduces truncation and rounding errors unless arbitrary-precision BigInt or logarithmic summation ($ln(n!)$) is utilized.