Permutation & Combination Calculator
Compute permutations P(n,k) and combinations C(n,k) (binomial coefficients) exactly using BigInt. Choose the operation, enter n and k (0 ≤ k ≤ n), optionally show steps, and export results.
Permutations & Combinations — Guide and Calculator
Permutations and combinations are fundamental counting tools in mathematics, statistics, and computer science. Whether you’re calculating the number of ways to order items, choosing teams, or deriving probabilities, understanding P(n,k) and C(n,k) is essential. This guide explains the definitions, efficient computation methods, worked examples, common pitfalls, and how to use this online calculator effectively.
Definitions
Permutation P(n,k): the number of ordered arrangements of k items selected from n distinct items. Formula:
P(n,k) = n × (n−1) × ... × (n−k+1) = n! / (n−k)!
Combination C(n,k): the number of unordered selections of k items from n distinct items (also “n choose k”):
C(n,k) = n! / (k! (n−k)!)
When to use which
Use permutations when order matters (arranging books on a shelf, PIN codes). Use combinations when order does not matter (selecting committee members, choosing lottery numbers). Example: arranging 3 out of 10 runners on a podium uses permutations (P(10,3)), while choosing 3 team members uses combinations (C(10,3)).
Efficient computation
Directly computing factorials can create huge intermediate values. To compute P(n,k) efficiently, multiply the descending k factors (n × (n−1) × ...), which avoids computing the full n!. For C(n,k), simplify by canceling factors between numerator and denominator progressively or compute using multiplicative formula:
C(n,k) = ∏_{i=1}^{k} (n−k+i)/i
This approach divides at each step to keep intermediate numbers smaller and maintain exactness when using BigInt, which this calculator implements.
Worked examples
Example 1 — Permutation: Number of ordered 4-letter codes from 26 letters without repetition: P(26,4) = 26×25×24×23 = 358,800.
Example 2 — Combination: Select 3 winners from 20 entrants: C(20,3) = 20!/(3!17!) = (20×19×18)/(3×2×1) = 1140.
Symmetry and identity
Combinations are symmetric:
C(n,k) = C(n, n−k)
Use this identity to reduce k when k > n/2 and speed up computation.
Large values and digit counts
Binomial coefficients can be enormous for large n and k; to estimate size use log-based approximations or Stirling’s formula to estimate factorial magnitudes. This calculator reports digit counts and can show summarized output if full integers are impractically large.
Probability applications
Combinations are used in probability for counting favorable outcomes over total outcomes. Example: probability of drawing 2 aces from a 52-card deck in 5 cards: favorable C(4,2)×C(48,3) divided by C(52,5).
Tips for using the calculator
- Ensure 0 ≤ k ≤ n — the tool will validate inputs and alert if invalid.
- For P(n,k), use the permutation mode to compute as a k-factor product (avoids large factorials).
- For C(n,k), use the multiplicative formula implemented to keep numbers small via stepwise division.
- Use “short” display mode to see digits & head/tail of huge results rather than full integers.
Edge cases
When k = 0, by convention P(n,0) = 1 and C(n,0) = 1 (empty selection). When k = n, P(n,n) = n! and C(n,n) = 1. If k > n the functions are undefined — this calculator prevents such inputs.
Computational complexity
Computing P(n,k) multiplicatively requires O(k) multiplications. Computing C(n,k) using the multiplicative formula requires O(k) operations with division each step. This is efficient compared to computing full factorials and is suitable for reasonably large inputs in the browser when using BigInt.
Conclusion
Permutations and combinations are straightforward to define but need careful numeric handling for large n or k. This calculator implements efficient exact methods (partial products and multiplicative formulas) and provides step-by-step logs to help you learn and verify computations. For massive, repeated, or performance-critical computations use server-side libraries with high-performance big-integer arithmetic.
Frequently Asked Questions (FAQs)
Permutations (P) count ordered arrangements; combinations (C) count unordered selections.
Non-negative integers n and k with 0 ≤ k ≤ n. The tool validates and warns about invalid entries.
Yes — the calculator uses BigInt and efficient simplifications to compute exact results; for extremely large n use server-side tools if needed.
Yes — enable 'Show steps' to see expanded product or multiplicative steps; large-step outputs are truncated to conserve resources.
The calculator uses C(n,k)=C(n,n−k) to reduce k when beneficial for speed and smaller intermediate values.
Yes — use combinations for counting outcomes in probability formulas; the tool also helps compute intermediate factorial terms.
Permutations with repetition have formula n^k. This page computes permutations without repetition; consider a separate calculator for repetition cases.
Often yes — computations are exact but result sizes grow; display mode can be switched to summary to avoid rendering huge integers.
Yes — by using BigInt and simplifying arithmetic stepwise, the calculator limits intermediate explosion while keeping exactness.
Yes — use the Download CSV button to save inputs, operation, result, step log and metadata.