dsa8 min read
Combinatorics nCr Modulo Prime Explained — Pascal Triangle, Factorial Inverse, Lucas Theorem [LC 62, Google, Meta]
Computing C(n, r) modulo a prime appears in nearly every counting problem at Google and Meta. Master Pascal triangle for small n, precomputed factorials with modular inverse for n up to 10^6, and Lucas theorem for n up to 10^18.
Read →