The many faces of the binomial coefficient: why nCr is so ubiquitous
Through Pascal's triangle, lattice paths, and the binomial theorem, we uncover the many identities of the binomial coefficient. We also cover the computational machinery essential for competitive programming: factorial tables with modular inverses, and Lucas' theorem for enormous indices.
The binomial coefficient begins life with the modest meaning "the number of ways to choose objects from ." Yet it appears everywhere in mathematics: in Pascal's triangle, in lattice path enumeration, in the expansion of , and in modular arithmetic for competitive programming. Why is so ubiquitous?
1 Definition and basic properties
2 Pascal's identity: the recursive structure
3 Lattice paths
4 The binomial theorem
5 Fast computation modulo a prime
In competitive programming, one frequently needs where is a prime (typically ).
Build a factorial table: for .
Build an inverse factorial table: , using Fermat's little theorem ( implies ).
6 Lucas' theorem
7 Takeaway
The binomial coefficient wears many hats: subset selection, lattice paths, polynomial expansion, set partition, and more.
Pascal's identity is the source of its recursive structure – and, equivalently, of the DP table known as Pascal's triangle.
The binomial theorem bridges algebra and combinatorics.
For computation modulo a prime, the factorial table with modular inverses handles most cases; Lucas' theorem covers extremely large indices with small primes.
In the next article, we investigate the curious "add, subtract, add, subtract..." pattern of the inclusion–exclusion principle and ask what makes the alternating signs give the right answer.
Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.