Combination & Permutation Calculator (nCr nPr)

Calculate combinations (nCr) and permutations (nPr) for probability and combinatorics problems

Enter the total number of items (n) and the number of items to select (r) to calculate combinations and permutations. This tool helps solve probability problems and combinatorial mathematics.

Combination & Permutation Calculator (nCr nPr)
Calculate combinations (nCr) and permutations (nPr) for probability and combinatorics problems

About Combination & Permutation Calculator

Combinations and permutations are two of the most fundamental concepts in combinatorics, a branch of mathematics concerned with counting, arrangement, and selection. Understanding the difference between them is essential for solving a wide variety of problems in probability theory, statistics, computer science, and everyday decision-making. A combination (denoted C(n, r) or nCr) counts the number of ways to select r items from a set of n distinct items when the order of selection does not matter. The formula is C(n, r) = n! / (r! × (n − r)!), where n! (n factorial) is the product of all positive integers up to n. For example, choosing 3 people from a group of 10 to form a committee gives C(10, 3) = 120 possible committees, because it does not matter in which order the members are chosen. A permutation (denoted P(n, r) or nPr) counts the number of ways to arrange r items selected from n distinct items when order does matter. The formula is P(n, r) = n! / (n − r)!. Using the same group of 10 people, if you want to assign a president, vice-president, and treasurer, the order is crucial, giving P(10, 3) = 720 arrangements. The key distinction is order. Ask yourself: does swapping two selected items create a meaningfully different outcome? If yes, you need permutations; if no, combinations apply. Card hands are combinations (ace-king-queen is the same hand regardless of draw order), but PIN codes are permutations (1-2-3-4 is different from 4-3-2-1). Combinations and permutations appear across countless real-world domains. In probability, they define the size of sample spaces needed to compute the likelihood of specific outcomes — for instance, the odds of winning a lottery by selecting 6 numbers from 49 is 1 in C(49, 6) = 13,983,816. In computer science, they are used to analyze algorithmic complexity, generate test cases, and design hash functions. In genetics, they model how alleles combine. In business, portfolio managers use them to enumerate possible asset allocations. This calculator supports three modes: combinations only, permutations only, or both simultaneously. Simply enter n (the total pool) and r (the selection size), choose your mode, and click Calculate Results. The tool handles all the factorial arithmetic instantly, even for large values of n where manual calculation would be impractical.

Examples

The table below shows representative combination and permutation problems with their solutions.

Input (n, r)ResultContext
n=52, r=5 (combinations)C(52,5) = 2,598,9605-card poker hands from a standard deck
n=10, r=3 (permutations)P(10,3) = 720Ways to assign 1st, 2nd, 3rd place to 10 runners
n=49, r=6 (combinations)C(49,6) = 13,983,816Lottery: choose 6 from 49 numbers
n=8, r=3 (both)C(8,3)=56, P(8,3)=336Committee vs ranked positions from 8 candidates

How to Use the Combination & Permutation Calculator

  1. Enter the total number of items available in the 'Total Items (n)' field. n must be a non-negative whole number.
  2. Enter how many items you want to select in the 'Selected Items (r)' field. r must satisfy 0 ≤ r ≤ n.
  3. Choose the Calculation Type: 'Combinations Only' if order does not matter, 'Permutations Only' if order matters, or 'Both' to see both results at once.
  4. Click 'Calculate Results' to instantly compute the answer using the formulas C(n,r) = n!/(r!(n−r)!) and P(n,r) = n!/(n−r)!.
  5. Use the quick-load example buttons below the table to pre-fill real-world scenarios and explore the results interactively.

Frequently Asked Questions

What is the difference between a combination and a permutation?
A combination counts selections where order does not matter, while a permutation counts arrangements where order does matter. For example, choosing 3 toppings for a pizza is a combination (pepperoni-mushroom-olive is the same as olive-mushroom-pepperoni), but assigning gold, silver, and bronze medals to 3 athletes is a permutation (each different ordering represents a different outcome).
Why is C(n, 0) = 1 and P(n, 0) = 1?
By mathematical convention, there is exactly one way to choose nothing from a set — the empty selection — and exactly one way to arrange zero items — the empty arrangement. This is consistent with the factorial definition 0! = 1, which ensures the formulas work correctly for r = 0.
Can r be larger than n?
No. You cannot select or arrange more items than are available in the set. If r > n, the result is mathematically undefined (division by a negative factorial), so the calculator will display an error. Make sure r ≤ n before clicking Calculate.
What is the relationship between C(n, r) and C(n, n−r)?
C(n, r) = C(n, n−r) because choosing r items to include is equivalent to choosing n−r items to exclude. For example, C(10, 3) = C(10, 7) = 120. This symmetry is called the complementary property of binomial coefficients and can simplify calculations when r is close to n.
How does this calculator handle large factorials?
JavaScript floating-point numbers support integers exactly up to about 2^53, and factorials grow extremely fast (20! ≈ 2.4 × 10^18, 21! overflows a 64-bit integer). The calculator uses an iterative multiplication approach for combinations to minimise overflow, but for very large n (above 170 or so) results may be expressed in scientific notation. For cryptographic-strength exact large integers, use a dedicated big-integer library.
Where are combinations and permutations used in real life?
They appear in lottery probability calculations, card game odds, sports bracket analysis, DNA sequence analysis, password security (counting possible combinations), scheduling and routing optimisation, and the design of experiments in statistics. Any time you need to count the number of ways to choose or arrange items without listing all possibilities individually, combinations or permutations provide the answer.