Skip to main content

Combinations and Permutations for Counting Problems

Calculate combinations (nCr) and permutations (nPr), with and without repetition. Explore how counts grow as n and r change.

Last Updated: February 13, 2026

Combinations and permutations answer the core question behind password strength, lottery odds, and seating charts: how many ways can you arrange or select items from a set? A hiring manager needed to know how many interview panels of 4 people could be formed from 12 candidates. She entered n = 12 and r = 4 into a combinations calculator, getting C(12, 4) = 495. The common mistake is mixing up combinations and permutations—choosing the wrong one doubles or halves the count in ways that wreck probability estimates. To interpret results correctly, always confirm whether your scenario cares about order: lottery numbers drawn don't care (combinations), but a ranked list of finalists does (permutations).

Order Matters or Not? Decide First

Before touching any formula, answer one question: does rearranging the chosen items create a different outcome? If picking A, B, C is the same as picking C, B, A, you need combinations. If the sequence matters—like assigning first, second, and third place—you need permutations.

Think about the physical result. A committee of three people is the same committee regardless of who was named first. But a three-digit lock code treats 1-2-3 as different from 3-2-1. Card hands are combinations; race finishing orders are permutations.

When order doesn't matter, dividing by r! removes the duplicate arrangements. That's why combinations are always smaller than or equal to permutations for the same n and r. The relationship is P(n, r) = C(n, r) × r!, meaning permutations count every ordering of each combination.

Quick test:

• "Does swapping two items change the outcome?" → Yes = permutation

• "Is the group the same regardless of arrangement?" → Yes = combination

nPr and nCr With Clear Formula Steps

Permutations without repetition: P(n, r) = n × (n−1) × (n−2) × … × (n−r+1). You multiply r consecutive integers starting from n. Choosing 3 items from 10: P(10, 3) = 10 × 9 × 8 = 720. Each position in the sequence pulls from a shrinking pool.

Combinations without repetition: C(n, r) = P(n, r) / r! = n! / (r!(n−r)!). The division removes duplicate orderings. C(10, 3) = 720 / 6 = 120. You can also compute it directly: (10 × 9 × 8) / (3 × 2 × 1).

Symmetry shortcut: C(n, r) = C(n, n−r). Choosing 3 from 10 is the same count as leaving out 7 from 10. When r is larger than n/2, compute the smaller side to reduce multiplication steps.

Example: C(52, 5) for poker hands

= (52 × 51 × 50 × 49 × 48) / (5 × 4 × 3 × 2 × 1)

= 311,875,200 / 120 = 2,598,960

With Repetition: When Duplicates Are Allowed

Permutations with repetition: n^r. Each of the r slots can be any of n options independently. A 4-digit PIN using digits 0–9 has 10^4 = 10,000 possibilities. This formula applies whenever you can reuse the same item in multiple positions.

Combinations with repetition use the "stars and bars" method: C(n + r − 1, r). Picking 5 scoops from 4 ice cream flavors, where order doesn't matter and repeats are allowed, gives C(4 + 5 − 1, 5) = C(8, 5) = 56. Visualize r stars (items) separated by n − 1 bars (dividers between categories).

Notice that with repetition r can exceed n—you can pick more items than there are categories. Without repetition r must be ≤ n because each item is used at most once.

Password example: An 8-character password from 62 characters (a–z, A–Z, 0–9) with repetition = 62^8 ≈ 218 trillion combinations.

Large Numbers: Avoid Overflow and Rounding

Factorials explode fast: 20! ≈ 2.4 × 10^18, already near JavaScript's safe integer limit. Computing 100! directly overflows any standard number type. Use multiplicative cancellation instead—compute the numerator and denominator in steps, canceling as you go.

For C(n, r), exploit symmetry: use k = min(r, n − r). C(100, 3) is easier than C(100, 97) even though they're equal. Multiply the top three terms (100 × 99 × 98) and divide by 3! = 6.

When results exceed 10^15, scientific notation is cleaner than long digit strings. The tool displays large outputs as 1.23e15 for readability. If you need exact counts for cryptographic key spaces or lottery audits, use arbitrary-precision libraries like Python's math.comb() or Mathematica.

Tip: If a homework problem gives a suspiciously large factorial, check whether the formula simplifies. C(1000, 2) = 1000 × 999 / 2 = 499,500—no need to compute 1000! at all.

Common Counting Mistakes to Avoid

Using permutation when combination is needed (or vice versa). This is the most frequent error. A student asked, "How many ways can I pick 3 toppings for my pizza?" If the pizza doesn't care about topping order, the answer is combinations. Multiplying by 3! gives a wildly inflated count.

Forgetting the repetition constraint. Picking lottery balls without replacement is combinations without repetition. Guessing a combination lock (where you can repeat digits) is permutations with repetition. The formulas differ by orders of magnitude.

Swapping n and r. C(5, 3) ≠ C(3, 5). The first asks how many ways to choose 3 from 5; the second is undefined because you can't pick more items than exist without repetition. Always verify that r ≤ n for standard combinations.

Ignoring indistinguishable items. If two of your items are identical, standard formulas overcount. Arranging the letters in "MISSISSIPPI" requires multinomial coefficients, not a plain permutation.

Sanity check: Combinations should always be ≤ permutations for the same n and r. If your combination result exceeds the permutation result, you've applied the formulas backwards.

Counting Problem Q&A

Why is 0! defined as 1?

By convention, 0! = 1 so that formulas stay consistent. C(n, 0) should equal 1 because there's exactly one way to choose nothing—do nothing. The formula n! / (0! × n!) only works if 0! = 1. It's a definitional choice that keeps everything tidy.

Can I have negative n or r?

Standard combinatorics uses non-negative integers. Negative factorials are undefined in elementary math. Extended definitions exist in advanced mathematics (the gamma function), but for counting problems, stick to n ≥ 0 and r ≥ 0.

What if items are not all distinct?

Use multinomial coefficients. The number of ways to arrange n items where n₁ are identical of one type, n₂ of another, etc., is n! / (n₁! × n₂! × …). "MISSISSIPPI" has 11 letters with 4 I's, 4 S's, 2 P's, and 1 M: 11! / (4! × 4! × 2! × 1!) = 34,650.

How do I calculate lottery odds?

For a 6/49 lottery (pick 6 numbers from 49, order irrelevant, no repeats), total outcomes = C(49, 6) = 13,983,816. Odds of matching all 6 = 1 in 13,983,816, or about 0.0000072%. If you pick more numbers, multiply by the probability of matching additional balls.

Why do passwords use permutations with repetition?

Each character position is independent, and you can use the same character more than once. A 12-character password from 95 printable ASCII characters has 95^12 ≈ 5.4 × 10^23 possibilities. That exponential growth is why longer passwords are exponentially harder to crack.

Limitations & Assumptions

• Distinct Items: Standard formulas assume all items are distinguishable. When some items are identical, use multinomial coefficients or adjust the formula to avoid overcounting.

• Integer Inputs: n and r must be non-negative integers. Fractional or negative values require advanced functions (gamma function) outside typical combinatorics.

• Computational Limits: Results involving factorials above 170 exceed JavaScript's floating-point range. For cryptographic key-space calculations or exact lottery audits, use arbitrary-precision arithmetic.

• Model Fit: Real-world constraints (dependencies, conditional rules, physical limits) may not fit pure combinatorial models. Verify that your scenario truly matches the mathematical assumptions.

Disclaimer: This calculator demonstrates counting concepts for learning purposes. For security audits, lottery system design, or professional probability work, use validated mathematical software and consult qualified experts.

Sources & References

Formulas and methods follow standard combinatorics references:

Frequently Asked Questions

Common questions about combinations and permutations, nCr and nPr formulas, factorials, stars and bars method, lottery odds, password security, and how to use this calculator for homework and statistics practice.

What is the difference between combinations and permutations?

The key difference is whether order matters. In combinations, selecting items A, B, C is the same as C, B, A—only the group matters, not the arrangement. In permutations, ABC and CBA are different because the sequence matters. Use combinations for selecting committees, lottery tickets, or poker hands. Use permutations for arranging books on a shelf, assigning race places, or creating ordered sequences.

When should I use 'with repetition' vs 'without repetition'?

Use 'without repetition' when each item can only be selected once (like dealing cards from a deck or choosing team members). Use 'with repetition' when items can be reused (like digits in a PIN code, where 1111 is valid, or selecting ice cream scoops where you can pick the same flavor multiple times).

What do n and r represent in these formulas?

n represents the total number of distinct items available to choose from. r represents how many items you're selecting or arranging. For example, choosing 5 cards from a 52-card deck means n=52 and r=5. The constraint r ≤ n applies to combinations and permutations without repetition, but r can exceed n when repetition is allowed.

Why do factorials grow so fast?

Factorials grow faster than exponential functions. For example: 10! = 3,628,800; 15! = 1,307,674,368,000; 20! ≈ 2.43 × 10^18. This rapid growth is why combinatorial problems quickly produce astronomically large numbers. The calculator handles this by using multiplicative simplification and displays large results in scientific notation.

What is the 'stars and bars' method for combinations with repetition?

Stars and bars is a combinatorial technique for distributing r identical items into n distinct bins (or choosing r items from n types with repetition). The formula C(n+r-1, r) counts ways to arrange r stars and n-1 bars. For example, choosing 5 donuts from 3 flavors: n=3, r=5, result = C(3+5-1, 5) = C(7,5) = 21 ways.

How do I calculate lottery odds?

Most lotteries use combinations without repetition because order doesn't matter and each number can only appear once. For a 6/49 lottery (pick 6 from 49 numbers), use C(49,6) = 13,983,816. Your odds of winning the jackpot are 1 in ~14 million. For Powerball-style lotteries with a separate bonus ball, multiply the main combination by the bonus ball options.

What's the relationship between combinations and permutations?

Permutations count all possible orderings of combinations. The formula P(n,r) = C(n,r) × r! shows that permutations equal combinations multiplied by the number of ways to arrange r items. For example, C(5,3) = 10 (groups of 3 from 5), while P(5,3) = 60 (ordered arrangements of 3 from 5). The ratio is 3! = 6.

Why is 0! equal to 1?

By convention, 0! = 1. This isn't arbitrary—it makes the formulas consistent. There's exactly one way to arrange zero items (do nothing), and the combination formula C(n,0) = n!/(0!×n!) should equal 1 (one way to choose nothing). The empty product convention in mathematics also defines an empty product as 1.

How many permutations are there for a 4-digit PIN?

For a 4-digit PIN using digits 0-9, use permutations with repetition: n^r = 10^4 = 10,000 possible PINs. Each position can be any of 10 digits, and digits can repeat. For a PIN where digits cannot repeat, use P(10,4) = 10×9×8×7 = 5,040 possible PINs.

What are some real-world applications of combinations and permutations?

Combinations: lottery probability, poker hand odds, selecting committee members, choosing pizza toppings, binomial coefficients in statistics. Permutations: password strength calculation, race finishing orders, seating arrangements, scheduling, encryption key spaces. These concepts are fundamental in probability, statistics, computer science, and cryptography.

Related Calculators

nCr / nPr Calculator: With or Without Repetition