Skip to Content
All memories

Permutations and Combinations - The Art and Science of Counting

 — #Mathematics#Combinatorics

The ability to count efficiently and accurately is fundamental not only in mathematics but also in numerous fields such as computer science, probability, statistics, and everyday problem-solving. Permutations and combinations are the core concepts of combinatorics that provide systematic methods for determining the number of ways objects can be arranged or selected. This exploration delves into these powerful tools, starting from the fundamental principles of counting and extending to more advanced theorems and applications.


The Ground Rules of Counting: Fundamental Principles – Multiply or Add

At the heart of combinatorics lie two basic principles that form the foundation for more complex counting techniques.

  • Multiplication Rule (Fundamental Principle of Counting): If a task can be performed in mm ways, and following this, a second task can be performed in nn ways, then the total number of ways to perform both tasks in succession is m×nm \times n. This principle extends to any number of sequential tasks. If there are kk tasks, and the first can be done in n1n_1 ways, the second in n2n_2 ways after the first, ..., and the kthk^{th} in nkn_k ways after the (k1)th(k-1)^{th}, then the total number of ways to perform all kk tasks is n1×n2××nkn_1 \times n_2 \times \dots \times n_k.

  • Addition Rule: If a task can be performed in mm ways and a second, mutually exclusive task can be performed in nn ways, then there are m+nm+n ways to perform either the first task or the second task. This rule applies when choices are alternative and cannot occur simultaneously.


Factorial Power: Notation and Prime Insights

The factorial of a non-negative integer nn, denoted by n!n!, represents the product of all positive integers less than or equal to nn. n!=n×(n1)×(n2)××3×2×1n! = n \times (n-1) \times (n-2) \times \dots \times 3 \times 2 \times 1 By definition, 0!=10! = 1. Factorials are fundamental in calculating permutations and combinations.

Exponent of a Prime pp in n!n! (Legendre's Formula)

To find the highest power of a prime number pp that divides n!n! (denoted Ep(n!)E_p(n!)), we use Legendre's Formula: Ep(n!)=k=1npk=np+np2+np3+E_p(n!) = \sum_{k=1}^{\infty} \left\lfloor \dfrac{n}{p^k} \right\rfloor = \left\lfloor \dfrac{n}{p} \right\rfloor + \left\lfloor \dfrac{n}{p^2} \right\rfloor + \left\lfloor \dfrac{n}{p^3} \right\rfloor + \dots where x\lfloor x \rfloor is the floor function, giving the greatest integer less than or equal to xx. The sum is finite because terms become zero when pk>np^k > n.


Order Matters: Permutations – Arranging Items

A permutation is an arrangement of a set of objects in a specific order.

  • Permutations of nn distinct objects taken rr at a time (P(n,r)P(n,r) or nPr^nP_r or PrnP^n_r): This is the number of ways to arrange rr objects chosen from nn distinct objects, where 0rn0 \le r \le n. P(n,r)=n!(nr)!=n(n1)(n2)(nr+1)P(n,r) = \dfrac{n!}{(n-r)!} = n(n-1)(n-2)\dots(n-r+1)

  • Permutations of nn distinct objects taken all at a time (P(n,n)P(n,n)): This is simply n!n!.

  • Permutations when some objects are identical: If there are nn objects in total, where p1p_1 objects are alike of one kind, p2p_2 objects are alike of another kind, ..., pkp_k objects are alike of a kthk^{th} kind, such that p1+p2++pk=np_1+p_2+\dots+p_k = n, then the number of distinct permutations is: n!p1!p2!pk!\dfrac{n!}{p_1! p_2! \dots p_k!}

  • Permutations with repetitions allowed: The number of permutations of nn distinct objects taken rr at a time, when repetition of objects is allowed, is nrn^r. Each of the rr positions can be filled in nn ways.


Order Doesn't Matter: Combinations – Selecting Items

A combination is a selection of objects from a set where the order of selection does not matter.

  • Combinations of nn distinct objects taken rr at a time (C(n,r)C(n,r) or nCr^nC_r or (nr)\binom{n}{r}): This is the number of ways to choose rr objects from nn distinct objects, where 0rn0 \le r \le n. Since each combination of rr objects can be permuted in r!r! ways, P(n,r)=C(n,r)×r!P(n,r) = C(n,r) \times r!. C(n,r)=(nr)=P(n,r)r!=n!r!(nr)!C(n,r) = \binom{n}{r} = \dfrac{P(n,r)}{r!} = \dfrac{n!}{r!(n-r)!}

  • Properties of C(n,r)C(n,r):

    • C(n,0)=1C(n,0) = 1 (one way to choose no objects)
    • C(n,n)=1C(n,n) = 1 (one way to choose all objects)
    • C(n,r)=C(n,nr)C(n,r) = C(n, n-r) (choosing rr objects is the same as choosing nrn-r objects to leave behind)
    • C(n,r)+C(n,r1)=C(n+1,r)C(n,r) + C(n, r-1) = C(n+1, r) (Pascal's Identity)
  • Combinations with repetitions allowed (Multiset Coefficient): The number of ways to choose rr items from nn distinct types of items, where repetition is allowed (also known as combinations with replacement), is given by the multiset coefficient: (n+r1r)=(n+r1n1)=(n+r1)!r!(n1)!\binom{n+r-1}{r} = \binom{n+r-1}{n-1} = \dfrac{(n+r-1)!}{r!(n-1)!} This can be visualized using the "stars and bars" method.


Going in Circles: Circular Permutations – Arrangements Around a Table

A circular permutation is an arrangement of objects in a circle. Unlike linear permutations, rotations of the same arrangement are considered identical.

  • Number of circular permutations of nn distinct objects: If we fix one object's position, the remaining n1n-1 objects can be arranged in (n1)!(n-1)! ways relative to it. So, the number of distinct circular permutations is (n1)!(n-1)!.

  • Circular permutations when clockwise and anti-clockwise arrangements are indistinguishable: If arrangements that are mirror images of each other (e.g., for necklaces or bracelets where flipping over doesn't change the arrangement) are considered the same, then the number of distinct circular permutations is (n1)!2\dfrac{(n-1)!}{2}, provided n>2n > 2. For n=1n=1, it's 0! = 1 (or (1-1)!/2 not well-defined). For n=2n=2, it's (2-1)! = 1. The division by 2 applies generally for n3n \ge 3.


Choosing Flexibly: All Possible Selections – Taking Some or All

This refers to the number of ways one can select items from a given set, allowing for different quantities of items to be selected.

  • Selecting one or more items from nn distinct items: For each of the nn items, there are two choices: either select it or not select it. This gives 2n2^n total possibilities. Since we want to select at least one item, we exclude the case where no item is selected. Number of ways = 2n12^n - 1. This can also be seen as C(n,1)+C(n,2)++C(n,n)C(n,1) + C(n,2) + \dots + C(n,n).

  • Selecting one or more items when items are not all distinct: Suppose there are pp items of one kind, qq items of another kind, rr items of a third kind, and so on. The number of ways to select some or all items from this collection is given by: (p+1)(q+1)(r+1)1(p+1)(q+1)(r+1)\dots - 1 The '1-1' excludes the case where no item is selected from any kind. For each kind, one can select 0,1,,p0, 1, \dots, p items (i.e., p+1p+1 ways).


Sharing is Caring: Divisions & Distributions – Grouping and Handing Out

This involves partitioning a set of items into groups or distributing them.

  • Division of nn distinct items into kk distinct groups of specified sizes n1,n2,,nkn_1, n_2, \ldots, n_k (where i=1kni=n\sum_{i=1}^k n_i = n): The number of ways is: n!n1!n2!nk!\dfrac{n!}{n_1! n_2! \dots n_k!} This is also the coefficient in the Multinomial Theorem.

  • Distribution of nn distinct items among kk distinct persons/boxes such that they receive n1,n2,,nkn_1, n_2, \ldots, n_k items respectively: This is the same as the division into distinct groups with specified sizes: n!n1!n2!nk!\dfrac{n!}{n_1! n_2! \dots n_k!}.

  • Division of nn distinct items into kk groups of equal size mm (so n=kmn=km):

    • If the kk groups are distinct (e.g., group A, group B, etc.): The number of ways is n!(m!)k\dfrac{n!}{(m!)^k}.
    • If the kk groups are identical (indistinguishable): The number of ways is n!k!(m!)k\dfrac{n!}{k!(m!)^k}. We divide by k!k! because the order of the identical groups does not matter.
  • Distribution of nn identical items into rr distinct boxes (Stars and Bars): This is equivalent to finding the number of non-negative integer solutions to x1+x2++xr=nx_1 + x_2 + \dots + x_r = n.

    • If boxes can be empty (i.e., xi0x_i \ge 0): The number of ways is (n+r1r1)\binom{n+r-1}{r-1} or (n+r1n)\binom{n+r-1}{n}.
    • If each box must contain at least one item (i.e., xi1x_i \ge 1): First, place one item in each of the rr boxes. Then distribute the remaining nrn-r identical items into rr distinct boxes without restriction. The number of ways is ((nr)+r1r1)=(n1r1)\binom{(n-r)+r-1}{r-1} = \binom{n-1}{r-1}.

Expanding with Flair: Multinomial Theorem – Generalizing Binomials

The Multinomial Theorem provides a formula for the expansion of a sum of multiple terms raised to a power, generalizing the Binomial Theorem. For any positive integer nn and any non-negative integers n1,n2,,nkn_1, n_2, \ldots, n_k such that n1+n2++nk=nn_1 + n_2 + \dots + n_k = n, the expansion of (x1+x2++xk)n(x_1 + x_2 + \dots + x_k)^n is given by: (x1+x2++xk)n=n1+n2++nk=nn!n1!n2!nk!x1n1x2n2xknk(x_1 + x_2 + \dots + x_k)^n = \sum_{n_1+n_2+\dots+n_k=n} \dfrac{n!}{n_1! n_2! \dots n_k!} x_1^{n_1} x_2^{n_2} \dots x_k^{n_k} The sum is taken over all possible combinations of non-negative integer indices n1n_1 through nkn_k such that their sum is nn. The coefficient n!n1!n2!nk!\dfrac{n!}{n_1! n_2! \dots n_k!} is called the multinomial coefficient, sometimes written as (nn1,n2,,nk)\binom{n}{n_1, n_2, \dots, n_k}.

  • The sum of all multinomial coefficients in the expansion (obtained by setting x1=x2==xk=1x_1=x_2=\dots=x_k=1) is knk^n.

The Pigeonhole Principle: Guaranteeing a Crowd

The Pigeonhole Principle is a simple yet surprisingly powerful concept in combinatorics that guarantees the existence of a certain condition without explicitly finding it.

  • Basic Principle: If you have more pigeons than pigeonholes, then at least one pigeonhole must contain more than one pigeon. Formally: If n+1n+1 items are put into nn containers, then at least one container must contain more than one item.

    • Proof by Contradiction: Assume no container has more than one item. Then the maximum number of items you could have is n×1=nn \times 1 = n. This contradicts the fact that we have n+1n+1 items. Therefore, the assumption must be false, and at least one container must have more than one item.
    • Example: In any group of 3 people, at least two must be of the same gender (pigeons=3, pigeonholes=2). In any group of 13 people, at least two must have their birthday in the same month (pigeons=13, pigeonholes=12).
  • Generalized Pigeonhole Principle: If NN objects are placed into kk boxes, then there is at least one box containing at least N/k\lceil N/k \rceil objects, where x\lceil x \rceil is the ceiling function, which rounds xx up to the nearest integer.

    • Example: In a group of 100 people, what is the minimum number of people who were born in the same month? Here, N=100N=100 people (objects) and k=12k=12 months (boxes). The minimum number guaranteed in at least one month is 100/12=8.33=9\lceil 100/12 \rceil = \lceil 8.33 \rceil = 9.

Counting Without Overcounting: Principle of Inclusion-Exclusion – The Venn Diagram Master

The Principle of Inclusion-Exclusion (PIE) is a counting technique that computes the number of elements in the union of multiple sets. It corrects for overcounting elements that belong to more than one set.

  • For two sets AA and BB: AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|
  • For three sets AA, BB, and CC: ABC=A+B+C(AB+AC+BC)+ABC|A \cup B \cup C| = |A| + |B| + |C| - (|A \cap B| + |A \cap C| + |B \cap C|) + |A \cap B \cap C|
  • General form for nn sets A1,A2,,AnA_1, A_2, \ldots, A_n: i=1nAi=iAii<jAiAj+i<j<kAiAjAk+(1)n1A1A2An\left| \bigcup_{i=1}^n A_i \right| = \sum_{i} |A_i| - \sum_{i<j} |A_i \cap A_j| + \sum_{i<j<k} |A_i \cap A_j \cap A_k| - \dots + (-1)^{n-1} |A_1 \cap A_2 \cap \dots \cap A_n| In a more compact notation: i=1nAi=I{1,,n}(1)I1iIAi\left| \bigcup_{i=1}^n A_i \right| = \sum_{\emptyset \neq I \subseteq \{1,\dots,n\}} (-1)^{|I|-1} \left| \bigcap_{i \in I} A_i \right|

PIE is often used to count the number of elements that satisfy at least one of several properties. To count elements satisfying none of the properties, one can use the complement: N(none)=UAiN(\text{none}) = |U| - |\bigcup A_i|.


Key Takeaways: The Essence of Order and Selection

Permutations and combinations are the foundational tools of combinatorics, providing systematic ways to count arrangements and selections.

  • Fundamental Principles: The Multiplication Rule (for sequential tasks) and Addition Rule (for mutually exclusive choices) are the building blocks for all counting methods.
  • Factorials (n!n!): Essential for calculating the number of arrangements of distinct objects. Legendre's formula helps determine prime factorizations.
  • Permutations (P(n,r)P(n,r)): Used when the order of arrangement matters. Formulas adapt for distinct objects, identical objects, and when repetition is allowed. Circular permutations handle arrangements in a loop.
  • Combinations (C(n,r)C(n,r)): Used when the order of selection does not matter. Formulas also adapt for distinct objects and when repetition is allowed (multisets).
  • Pigeonhole Principle: A powerful non-constructive tool that guarantees that if there are too many items to fit into too few categories, at least one category must contain multiple items.
  • Divisions and Distributions: Provide methods for partitioning sets into groups or distributing items into distinct or identical containers, with various constraints.
  • Multinomial Theorem: Generalizes the binomial expansion for powers of sums with multiple terms, with coefficients determined by combinatorial arguments.
  • Principle of Inclusion-Exclusion: A powerful technique for counting elements in the union of several sets by systematically adding and subtracting the sizes of their intersections to correct for overcounting.

These principles are not merely abstract mathematical exercises; they are critical for calculating probabilities, analyzing algorithms, designing experiments, and solving a wide array of problems where the number of possible outcomes or configurations needs to be determined.