Lucas's theorem

In number theory, Lucas's theorem expresses the remainder of division of the binomial coefficient $$\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:
 * $$\binom{m}{n}\equiv\prod_{i=0}^k\binom{m_i}{n_i}\pmod p,$$

where
 * $$m=m_kp^k+m_{k-1}p^{k-1}+\cdots +m_1p+m_0,$$

and
 * $$n=n_kp^k+n_{k-1}p^{k-1}+\cdots +n_1p+n_0$$

are the base p expansions of m and n respectively. This uses the convention that $$\tbinom{m}{n} = 0$$ if m < n.

Proofs
There are several ways to prove Lucas's theorem.

$$

$$

Consequences

 * A binomial coefficient $$\tbinom{m}{n}$$ is divisible by a prime p if and only if at least one of the base p digits of n is greater than the corresponding digit of m.
 * In particular, $$\tbinom{m}{n}$$ is odd if and only if the binary digits (bits) in the binary expansion of n are a subset of the bits of m.

Non-prime moduli
Lucas's theorem can be generalized to give an expression for the remainder when $$\tbinom mn$$ is divided by a prime power pk. However, the formulas become more complicated.

If the modulo is the square of a prime p, the following congruence relation holds for all 0 ≤ s ≤ r ≤ p − 1, a ≥ 0, and b ≥ 0.
 * $$\binom{pa+r}{pb+s}\equiv\binom ab\binom rs(1+pa(H_r-H_{r-s})+pb(H_{r-s}-H_s))\pmod{p^2},$$

where $$H_n=1+\tfrac12+\tfrac13+\cdots+\tfrac1n$$ is the nth harmonic number.

Generalizations of Lucas's theorem for higher prime powers pk are also given by Davis and Webb (1990) and Granville (1997).

Variations and generalizations

 * Kummer's theorem asserts that the largest integer k such that pk divides the binomial coefficient $$\tbinom{m}{n}$$ (or in other words, the valuation of the binomial coefficient with respect to the prime p) is equal to the number of carries that occur when n and m − n are added in the base p.


 * The q-Lucas theorem is a generalization for the q-binomial coefficients, first proved by J. Désarménien.