In number theory, Lucas's theorem expresses the remainder of division of the binomial coefficient ( m n ) {\displaystyle {\tbinom {m}{n}}} by a prime number p in terms of the base p expansions of the integers m and n. Lucas's theorem first appeared in 1878 in papers by Édouard Lucas.
Statement For non-negative integers m and n and a prime p, the following congruence relation holds:
( m n ) ≡ ∏ i = 0 k ( m i n i ) ( mod p ) , {\displaystyle {\binom {m}{n}}\equiv \prod _{i=0}^{k}{\binom {m_{i}}{n_{i}}}{\pmod {p}},}
where
m = m k p k + m k − 1 p k − 1 + ⋯ + m 1 p + m 0 , {\displaystyle m=m_{k}p^{k}+m_{k-1}p^{k-1}+\cdots +m_{1}p+m_{0},}
and
n = n k p k + n k − 1 p k − 1 + ⋯ + n 1 p + n 0 {\displaystyle n=n_{k}p^{k}+n_{k-1}p^{k-1}+\cdots +n_{1}p+n_{0}}
are the base p expansions of m and n respectively. This uses the convention that ( m n ) = 0 {\displaystyle {\tbinom {m}{n}}=0} if m < n.
Proofs There are several ways to prove Lucas's theorem.
Consequences One consequence of Lucas's theorem is that the binomial coefficient ( m n ) {\displaystyle {\tbinom {m}{n}}} is divisible by the prime p if and only if at least one of the digits of the base-p representation of n is greater than the corresponding digit of m. In particular, ( m n ) {\displaystyle {\tbinom {m}{n}}} is odd if and only if the positions of the ones in the binary expansion of n are a subset of the positions of the ones in that of m. This leads to a peculiar distribution of odd numbers in Pascal's triangle, resembling Sierpiński 's triangle, shown to the right.
Non-prime moduli Lucas's theorem can be generalized to give an expression for the remainder when ( m n ) {\displaystyle {\tbinom {m}{n}}} is divided by a prime power pk. However, the formulas become more complicated. If the modulus is the square of a prime p, the following congruence relation holds for all 0 ≤ s ≤ r ≤ p − 1, a ≥ 0, and b ≥ 0:
… excerpt ends here. Continue reading the full article.

