Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Combinatorics Basics: Counting Rules and Scenarios





Combinatorics: The Art of Counting


Combinatorics is the branch of mathematics that deals with counting, arrangement, and selection of objects. At its core, it answers fundamental questions: "In how many ways can this be done?" and "How many possibilities exist?" This field transforms seemingly simple counting problems into powerful mathematical tools that reveal hidden patterns and structures.

Combinatorics serves as a bridge connecting multiple mathematical disciplines. It provides the foundation for probability theory, where calculating favorable outcomes requires systematic counting techniques. The field draws heavily from set theory when dealing with collections and their intersections, while its applications extend into graph theory through network analysis and path counting. Number theory benefits from combinatorial methods in partition problems and divisibility questions, and linear algebra uses combinatorial principles in matrix theory and vector spaces.

The problems combinatorics solves range from practical applications—like determining optimal seating arrangements or analyzing computer algorithms—to abstract mathematical questions about infinite structures. Whether you're calculating lottery odds, designing efficient networks, or exploring mathematical proofs, combinatorics provides the essential counting framework.

In this section, we'll explore the fundamental counting principles, dive into permutations and combinations, and tackle real-world combinatorial scenarios that demonstrate the power and elegance of this mathematical art.



Counting Principles

A lunch menu has 3 soups and 4 salads. How many different lunches are there?
The answer depends on the deal: either a soup or a salad, or one soup and one salad together.
Side by side, "or" gives 7 lunches and "and" gives 12.
lunch dealhow one lunch is builtnumber of lunchesrule
a soup or a saladone choice from two separate groups3 + 4 = 7addition
a soup and a saladone choice at each of two stages3 · 4 = 12multiplication
With "or", each lunch is one of the 33 soups or one of the 44 salads. With "and", each of the 33 soups can be paired with each of the 44 salads.
Alternatives add; stages multiply.
Which of the two rules applies depends on how an outcome is built. When a single choice is made from one of several separate groups, the groups are alternatives and each option belongs to exactly one of them. When an outcome needs one choice at each of several stages, every option at one stage can be combined with every option at the next. The linking word in the problem often shows which structure is present: "or" joins alternatives, "and" joins stages.
The definition
The counting principles are the rules for combining counts: the addition rule for mutually exclusive alternatives and the multiplication rule for successive choices, with three further rules built on these two.
Five logical rules govern how counts combine:
• Addition rule — when options are mutually exclusive, the counts add. mm ways for one method and nn ways for another, with no overlap, gives m+nm + n total.
• Multiplication rule — when choices are sequential and independent, the counts multiply. mm outcomes for step 1 and nn outcomes for step 2 give m⋅nm \cdot n combined outcomes.
• Complementary counting — reframes "at least one" problems by counting their negation (the "none" case) and subtracting from the total.
• Double counting — proves identities by counting the same set in two different ways and equating the two expressions.
• Pigeonhole principle — guarantees that when more items are distributed than there are containers, at least one container must hold a repeat.
The first two are foundational; the other three extend or apply them.
So "soup or salad" gives 3+4=73 + 4 = 7 lunches and "soup and salad" gives 3⋅4=123 \cdot 4 = 12.
These rules are the basic tools behind every count in combinatorics.
Permutations, combinations and the binomial coefficient, later on this page, all come from using the multiplication and addition rules over and over. Each rule is treated in full on the counting principles page.
Using the wrong rule is the commonest counting mistake.
Pitfall: Adding counts of sequential choices
Counting outfits of one shirt from 55 and one pair of trousers from 33 as 5+3=85 + 3 = 8 treats the two choices as alternatives. Each shirt goes with each pair, so there are 5⋅3=155 \cdot 3 = 15 outfits.
Alternatives that overlap need a correction to the addition rule, set out in when counts overlap.
The rest of the page covers inclusion-exclusion, permutations and combinations, standard scenarios, the binomial coefficient and the binomial theorem.

When Counts Overlap: Inclusion–Exclusion


The addition rule has a quiet requirement — the options must be mutually exclusive. The moment two sets share elements, simply adding their sizes counts the shared elements twice.

The inclusion–exclusion principle is the systematic correction. For two sets:

Inclusion-Exclusion Principle (Two Sets)
∣A∪B∣=∣A∣+∣B∣−∣A∩B∣.|A \cup B| = |A| + |B| - |A \cap B|.
Learn more about this formula: Inclusion-Exclusion Principle (Two Sets) →


Pitfall: Dropping the triple intersection
Counting 11 to 3030 divisible by 22, 33 or 55 as 15+10+6−5−3−2=2115 + 10 + 6 - 5 - 3 - 2 = 21 loses 3030, which is added three times and subtracted three times. Adding back the triple term gives 21+1=2221 + 1 = 22.

For three sets the pattern continues — add singles, subtract pairwise intersections, add the triple intersection. For nn sets the signs alternate down the line, with one term for every non-empty subset of the sets involved.

The principle also has a complementary form, counting elements that belong to none of the listed sets. This is the form behind the derangement count and other "at least one" or "none" results.

Permutations and Combinations


A permutation is an ordered arrangement of items. Arranging nn distinct items in a row gives n!n! permutations — the factorial and arrangement marks are unpacked in permutation notation. Selecting and arranging rr items from nn gives

Permutations and Combinations
P(n,r)=n!(n−r)!.P(n,r) = \frac{n!}{(n-r)!}.

Variants of the basic problem cover arrangements with repetition allowed, arrangements containing identical items, circular arrangements, and arrangements with positional constraints.

Fact: A shuffled deck is almost surely new
A deck has 52!≈8×106752! \approx 8 \times 10^{67} orders. Even a billion shuffles a second since the Big Bang would deal fewer than 102710^{27} decks, so a well-shuffled deck is almost certainly in an order no deck has ever had.

Factorials grow faster than any exponential cnc^n. Each item added to a row multiplies the number of arrangements by the new length of the row: 5!=1205! = 120, 10!=3,628,80010! = 3{,}628{,}800, and 20!20! is already above 2×10182 \times 10^{18}. A standard deck of cards is a row of 5252 distinct items, and every shuffle produces one of its 52!52! orders.

A combination is an unordered selection of items. Choosing rr items from nn without regard to order gives

Combination
(nr)=n!r!(n−r)!.\binom{n}{r} = \frac{n!}{r!(n-r)!}.
Learn more about this formula: Combination →


Pitfall: Using a permutation for a selection
Counting committees of 33 from 1010 people as P(10,3)=720P(10,3) = 720 treats each order of the same three members as a new committee. A committee has no order, so the count is (103)=120\binom{10}{3} = 120.

The two formulas are closely linked. Every unordered selection of rr items can be lined up in r!r! different orders, so each combination stands for exactly r!r! permutations, and (nr)=P(n,r)r!\binom{n}{r} = \frac{P(n,r)}{r!}. Which count a problem needs depends on whether two outcomes with the same items in a different order are treated as different outcomes.

Variants cover partitioning items into groups, distributing identical items into labeled cells, and weak and strong compositions.

All of these formulas are built from a handful of combinatorial symbols — the factorial n!n!, the arrangement count P(n,r)P(n,r), the binomial coefficient (nr)\binom{n}{r} — each listed in the symbols reference with the LaTeX code that produces it, and the mathematical keyboard lets you type them directly.

To evaluate the factorials in these formulas, use the factorial calculator.
DownloadPNG2×PDF
One question first
Selecting rr items from nn distinct items: whether the order of the selected items matters decides which count applies.
Selecting r from n
rr items from nn
split by whether order matters
P
Case 1
order matters
Permutation
an ordered arrangement; see permutations
P(n,r)=n!(n−r)!P(n,r) = \dfrac{n!}{(n-r)!}
C
Case 2
order does not matter
Combination
an unordered selection
(nr)=n!r!(n−r)!\dbinom{n}{r} = \dfrac{n!}{r!(n-r)!}
Variants
Each family has variants: repetition, identical items, circular arrangements and constraints for permutations; groups, distributions and compositions for combinations.
Permutation or combination: does order matter?·/combinatorics/basicsLearn Math Class
Whether order matters splits every counting formula in two: arrangements count each order, selections divide the orders out.

Standard Scenarios


Within the two families, problems reduce to ten standard templates — five permutation scenarios and five combination scenarios. Each scenario asks a distinct structural question and has a known formula. Permutation scenarios come first and combination scenarios after them, with each scenario paired with its counterpart on the opposite side.

Permutation Scenarios


• Full permutation — arrange nn distinct items in a row: n!n!
• Permutation with identical items — arrange nn items where n1,n2,…,nkn_1, n_2, \ldots, n_k are identical of each type: n!n1! n2!⋯nk!\dfrac{n!}{n_1!\, n_2! \cdots n_k!}
• Partial permutation without repetition — arrange rr items chosen from nn distinct: n!(n−r)!\dfrac{n!}{(n-r)!}
• Permutation with repetition — fill rr positions from nn choices with repetition allowed: nrn^r
• Circular permutation — arrange nn items in a circle: (n−1)!(n-1)!

Combination Scenarios


• Simple combination — choose rr items from nn: (nr)\binom{n}{r}
• Partition into groups — split nn items into labeled groups of sizes k1,k2,…,krk_1, k_2, \ldots, k_r: (nk1,k2,…,kr)\binom{n}{k_1, k_2, \ldots, k_r}
• Weak composition — distribute nn identical items into rr bins, bins allowed empty: (n+r−1r−1)\binom{n+r-1}{r-1}
• Strong composition — distribute nn identical items into rr bins, no bin empty: (n−1r−1)\binom{n-1}{r-1}
• Distribution into cells — distribute nn distinct items into rr labeled cells, cells allowed empty: rnr^n

Pitfall: Swapping base and exponent
Counting ways to drop 33 distinct letters into 44 mailboxes as 34=813^4 = 81 has each mailbox choosing a letter. Each letter chooses a mailbox, so the count is 43=644^3 = 64.

Two of the formulas above are powers, and both come from the multiplication rule. In a permutation with repetition, each of the rr positions is filled from the nn choices, giving one factor of nn per position. In a distribution into cells, each of the nn items is sent to one of the rr cells, giving one factor of rr per item.

To count arrangements and selections for your own numbers in each of these scenarios, use the combinatorics calculator.
DownloadPNG2×PDF
Before you read
Ten templates for counting problems
Almost every counting problem matches one of ten standard scenarios. The first split is whether the order of the chosen items matters.
  • L0Standard counting scenariosten templates
    • L1Permutation scenariosorder matters
      • L2Full permutationarrange n distinct items in a rown!
      • L2With identical itemsn items, n₁ … nₖ of each typen!/(n₁!…nₖ!)
      • L2Partial, no repetitionarrange r chosen from nn!/(n−r)!
      • L2With repetitionfill r positions from n choicesnʳ
      • L2Circulararrange n items in a circle(n−1)!
    • L1Combination scenariosorder does not matter
      • L2Simple combinationchoose r items from nC(n, r)
      • L2Partition into groupssplit n items into labeled groupsmultinomial
      • L2Weak compositionn identical items into r bins, empty allowedC(n+r−1, r−1)
      • L2Strong compositionn identical items into r bins, none emptyC(n−1, r−1)
      • L2Distribution into cellsn distinct items into r labeled cellsrⁿ
Takeaway
Find the template, then the formula
Decide whether order matters, then whether items repeat or are identical; the matching scenario hands you the formula.
Ten standard counting scenarios·/combinatorics/basicsLearn Math Class

The Binomial Coefficient


The combination formula (nr)\binom{n}{r} counts how many rr-element subsets exist in an nn-element set. The same expression keeps appearing in other contexts — in permutation formulas, in algebraic identities, in probability distributions — so it is worth examining as a mathematical object in its own right rather than only as a counting answer.

The coefficient satisfies relations that are not visible from the counting interpretation. The symmetry (nk)=(nn−k)\binom{n}{k} = \binom{n}{n-k} follows immediately from the definition. Pascal's rule,

The Binomial Coefficient
(nk)=(n−1k−1)+(n−1k),\binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k},

arranges all binomial coefficients into Pascal's triangle, where each interior entry is the sum of the two directly above. Further identities organize entire row sums and diagonal patterns.

The coefficient also generalizes to the multinomial coefficient (nk1,k2,…,kr)\binom{n}{k_1, k_2, \ldots, k_r}, which counts arrangements of items partitioned into multiple groups of identical types.
n = 0n = 1n = 2n = 3n = 4n = 5n = 61111211331146C(4, 2)41151010511615201561ROW 4 = COEFFICIENTS OF (a + b)⁴(a + b)⁴ = a⁴ + 4a³b + 6a²b² + 4ab³ + b⁴
C(4,2) = C(3,1) + C(3,2)

The highlighted entry is the sum of the two directly above it, which is Pascal’s rule read off the array instead of out of the formula. Every interior entry is built the same way, so the whole triangle can be generated from its edges of 1s without evaluating a single factorial. Focus any entry and watch its two parents light up on the Pascal’s triangle visualizer.

Seen that way the binomial coefficient is not only an answer to a counting question but an entry in a structure, and the identities above are statements about where it sits in that structure.

The Binomial Theorem


The binomial coefficient's algebraic side becomes explicit in the expansion of (a+b)n(a+b)^n. Multiplying out the product distributes into terms of the form an−kbka^{n-k} b^k. The number of times each such term appears equals the number of ways to choose kk of the nn factors to contribute a bb — which is exactly (nk)\binom{n}{k}. The result is the binomial theorem:

Binomial Theorem
(a+b)n=∑k=0n(nk) an−kbk.(a+b)^n = \sum_{k=0}^{n} \binom{n}{k} \, a^{n-k} b^k.
Learn more about this formula: Binomial Theorem →


Pitfall: Forgetting the power on b
Taking the x2x^2 term of (x+2)4(x + 2)^4 as (42)x2⋅2=12x2\binom{4}{2} x^2 \cdot 2 = 12x^2 leaves the 22 without its power. With bk=22=4b^k = 2^2 = 4, the term is 6⋅4 x2=24x26 \cdot 4\, x^2 = 24x^2.

Each term of the expansion has three parts: the coefficient (nk)\binom{n}{k}, the power an−ka^{n-k} and the power bkb^k, with the two exponents always adding up to nn. When aa or bb is a number, or a variable with a coefficient, its power is a number too, and it multiplies into the coefficient of the term. Only for (x+y)n(x + y)^n are the coefficients read directly from a row of Pascal's triangle.

The theorem generalizes — the multinomial theorem expands (x1+x2+⋯+xr)n(x_1 + x_2 + \cdots + x_r)^n using multinomial coefficients.

Common Pitfalls

Five mistakes come up again and again in basic counting problems. Each is marked where it happens in the sections above; here each is worked through in full, with the wrong and the right working side by side.
DownloadPNG2×PDF
1Adding counts of sequential choices
An outcome is built in stages, one choice at each stage, but the counts of the stages are added as if they were alternatives. The sum counts the options at the stages, not the ways to combine them.
Wrong turn
Error here
An outfit is one of 55 shirts and one of 33 pairs of trousers, so there are 5+3=85 + 3 = 8 outfits.
Right path
Every shirt can be worn with every pair of trousers. The multiplication rule gives 5⋅3=155 \cdot 3 = 15 outfits.
Why it happensBoth rules start from the same numbers, and "5 shirts and 3 pairs of trousers" reads like a list of things to total. The addition rule fits only when exactly one option is picked from one of the groups.
How to checkList the outcomes for a single shirt. It already gives 33 outfits, one with each pair of trousers, so 55 shirts give 55 groups of 33.
2Dropping the triple intersection
With three sets, the pairwise intersections are subtracted and the calculation stops there. Elements that lie in all three sets were added three times and subtracted three times, so they are no longer counted at all.
Wrong turn
Error here
For the numbers 11 to 3030 divisible by 22, 33 or 55, ∣A∣=15|A| = 15, ∣B∣=10|B| = 10, ∣C∣=6|C| = 6, ∣A∩B∣=5|A \cap B| = 5, ∣A∩C∣=3|A \cap C| = 3 and ∣B∩C∣=2|B \cap C| = 2, so the count is 15+10+6−5−3−2=2115 + 10 + 6 - 5 - 3 - 2 = 21.
Right path
The triple intersection holds the multiples of 3030, so ∣A∩B∩C∣=1|A \cap B \cap C| = 1 and ∣A∪B∪C∣=21+1=22|A \cup B \cup C| = 21 + 1 = 22.
Why it happensThe two-set formula ends with a subtraction, and the three-set version is remembered as "add the sets, subtract the overlaps" without its last term.
How to checkCount the complement. The numbers from 11 to 3030 divisible by none of 22, 33 and 55 are 1,7,11,13,17,19,23,291, 7, 11, 13, 17, 19, 23, 29. There are 88 of them, and 30−8=2230 - 8 = 22.
3Using a permutation for a selection
A problem that asks only which items are chosen is counted with P(n,r)P(n,r), the formula for ordered arrangements. Each selection is then counted once for every order of its items.
Wrong turn
Error here
A committee of 33 from 1010 people is counted as P(10,3)=10⋅9⋅8=720P(10,3) = 10 \cdot 9 \cdot 8 = 720.
Right path
A committee has no first, second or third member, so order does not matter: (103)=7203!=7206=120\binom{10}{3} = \frac{720}{3!} = \frac{720}{6} = 120.
Why it happensPicking the members one after another feels like a sequence of choices, and the multiplication rule naturally produces 10⋅9⋅810 \cdot 9 \cdot 8.
How to checkSwap two chosen items. If Ann, Ben, Cat and Cat, Ben, Ann describe the same committee, order does not matter and the ordered count must be divided by r!r!.
4Swapping base and exponent
In a power formula such as rnr^n for a distribution into cells, the number of items and the number of cells trade places. The count then answers a different question.
Start
33 distinct letters are dropped into 44 mailboxes, and a mailbox may stay empty.
Wrong turn
Error here
The count is given as 34=813^4 = 81.
Right path
Each of the 33 letters chooses one of the 44 mailboxes, so the count is 4⋅4⋅4=43=644 \cdot 4 \cdot 4 = 4^3 = 64.
Why it happensThe two power formulas on the page, nrn^r and rnr^n, look alike, and the letters nn and rr stand for different things in the two scenarios.
How to checkTry a single letter. It can go into any of the 44 mailboxes, which 41=44^1 = 4 gives and 14=11^4 = 1 does not.
5Forgetting the power on b
A term of the binomial expansion is written with its coefficient (nk)\binom{n}{k} and the power of the variable, but the number in the binomial is not raised to its power.
Wrong turn
Error here
The x2x^2 term of (x+2)4(x + 2)^4 has k=2k = 2, and it is written as (42)x2⋅2=6⋅2 x2=12x2\binom{4}{2} x^2 \cdot 2 = 6 \cdot 2\, x^2 = 12x^2.
Right path
The term is (42)x2⋅22=6⋅4 x2=24x2\binom{4}{2} x^2 \cdot 2^2 = 6 \cdot 4\, x^2 = 24x^2. The full expansion is (x+2)4=x4+8x3+24x2+32x+16(x + 2)^4 = x^4 + 8x^3 + 24x^2 + 32x + 16.
Why it happensIn (a+b)n(a + b)^n with letters, bkb^k looks like bookkeeping for the variables, and when bb is a number its power is easy to lose.
How to checkSet x=1x = 1. The expansion must equal (1+2)4=81(1 + 2)^4 = 81, and 1+8+24+32+16=811 + 8 + 24 + 32 + 16 = 81; with 12x212x^2 in place of 24x224x^2 the sum is only 6969.
Common pitfalls in basic counting·/combinatorics/basicsLearn Math Class
Each slip uses the right numbers in the wrong rule. Independent choices multiply, a selection without order divides the ordered count by r!r!, the exponent counts the choices made, the triple intersection goes back in, and the binomial term raises bb to the power kk. Trying a small case such as one shirt or one letter, counting the complement, or setting x=1x = 1 catches each slip.

Related Concepts


• Probability — counting favorable outcomes against total outcomes is the bridge from combinatorics into probability.

• Set Theory — the formal language of unions, intersections, and partitions on which the counting principles are stated.

• Algebra — binomial and polynomial expansions, and the algebraic identities that arise from combinatorial counts.

• Linear Algebra — combinatorial structures appear in matrices and in permutations as transformations.

Combinatorics FAQ

What is combinatorics actually used for?

+
Counting things that are too numerous to list. It underpins probability, where you need the size of a sample space, and appears throughout cryptography, network design, scheduling, and algorithm analysis. Anywhere a question asks how many arrangements, selections, or configurations exist, combinatorics supplies the method for answering it without enumeration.Read more →

How do you tell whether order matters in a counting problem?

+
Ask whether swapping two chosen items produces a different outcome. Assigning first and second place gives different results when swapped, so order matters. Picking two people for a committee does not, since the same pair results either way. This single test decides which family of formulas applies before any arithmetic starts.Read more →

Why are combinatorics problems hard even when the formulas are simple?

+
Because the difficulty is recognition, not calculation. The formulas are short, but choosing among them requires deciding whether order matters, whether repetition is allowed, and whether the items are distinguishable. Two problems with almost identical wording can need entirely different approaches, which is why practice focuses on classifying rather than computing.Read more →

Has a shuffled deck of cards ever been in the same order before?

+
Almost certainly not, if the shuffle is thorough. A deck of 5252 cards has 52!≈8×106752! \approx 8 \times 10^{67} possible orders. Even a billion shuffles a second since the Big Bang would have dealt fewer than 102710^{27} decks, a tiny fraction of that total, so a well-shuffled deck is almost surely in an order no deck has ever had.Read more →

Do factorials grow faster than exponentials?

+
Yes. Going from n!n! to (n+1)!(n+1)! multiplies by n+1n + 1, while each step of cnc^n multiplies by the same cc, so once n+1n + 1 is larger than cc the factorial gains at every step and must overtake. It passes 2n2^n at n=4n = 4, where 24>1624 > 16, and 10n10^n only at n=25n = 25, but it always gets there. Already 20!20! is above 2×10182 \times 10^{18}.Read more →