Notation: C(n, k) is the binomial coefficient, v_p the exponent of the prime p (the p-adic valuation), s_p(n) the sum of the base-p digits of n, and n_i, k_i the base-p digits of n and k. The picture shows C(n, k) mod m for 0 ≤ k ≤ n < N, with N = 4096 on large screens and N = 2048 on small ones.
Proven Lucas' theorem
C(n, k) ≡ ∏i C(ni, ki) (mod p), n = ∑ ni pi, k = ∑ ki pi, 0 ≤ ni, ki < p
Proof in one line: (1 + x)^p ≡ 1 + x^p (mod p), hence (1 + x)^n ≡ ∏ (1 + x^(p^i))^(n_i); compare the coefficients of x^k. Consequence used by the picture: the first p^(j+1) rows consist of p(p + 1)/2 copies of the first p^j rows, each multiplied by a non-zero constant C(a, b) with a < p, separated by blocks of zeros. The page does not assume this: the residues are computed with the addition rule of Pascal's triangle, and the digit product is compared with them cell by cell.
Proven Kummer's theorem
vp(C(n, k)) = #{carries in k + (n − k), base p} = (sp(k) + sp(n − k) − sp(n)) / (p − 1)
It follows from Legendre's formula v_p(n!) = (n − s_p(n)) / (p − 1). The colouring “Carries” shows v_p(C(n, k)), capped at 7. For a composite modulus m = ∏ q^e the rule is: m divides C(n, k) exactly when, for every prime power q^e of m, the addition in base q has at least e carries. This one statement explains all the composite pictures.
Proven Glaisher (p = 2) and Fine (any prime)
#{k : p ∤ C(n, k)} = ∏i (ni + 1); p = 2: 2s₂(n)
A direct consequence of Lucas' theorem: C(n, k) is not divisible by p exactly when every digit of k is at most the digit of n above it, which leaves n_i + 1 choices for each digit. For p = 2 this is 2^(s_2(n)), Gould's sequence (OEIS A001316).
Proven Counting and dimension
#{(n, k) : n < pj, p ∤ C(n, k)} = (p(p + 1)/2)j, Dp = log(p(p + 1)/2) / log p
Summing Fine's product over all n < p^j gives (1 + 2 + … + p)^j = (p(p + 1)/2)^j. After rescaling, the limit set is exactly self-similar with p(p + 1)/2 pieces scaled by 1/p, so its similarity dimension, which equals its box-counting and Hausdorff dimension, is log(p(p + 1)/2) / log p (Wolfram 1984). The share of entries not divisible by p among the first p^j rows is ((p + 1)/(2p))^j · 2p^j/(p^j + 1), which tends to 0. For every modulus m, prime or not, almost all binomial coefficients are divisible by m (Singmaster 1974).
Proven The prime row test
n prime ⇔ n | C(n, k) for all 0 < k < n
If n is prime, then n divides n!/(k!(n − k)!) for 0 < k < n, because n divides the numerator and not the denominator. If n is composite and p is its smallest prime factor, then v_p(C(n, p)) = v_p(n) − 1, so n does not divide C(n, p). In the colouring “Prime rows” a cell is lit when n does not divide C(n, k), decided with Kummer's theorem for every prime power of n. The same fact, written as (x + 1)^n ≡ x^n + 1 (mod n), is the starting point of the AKS primality test. It is a beautiful criterion, not a fast one: row n has n + 1 numbers.
Proven Composite moduli
For m = 2 · 3 the zero set is the intersection of the zero sets mod 2 and mod 3 (Chinese remainder theorem); the two patterns scale by 2 and by 3, and no power of 2 is a power of 3. For a prime power p^e the picture still has a hierarchical structure, and Lucas' theorem has extensions to prime powers (Davis and Webb 1990, Granville 1997), but one tile is no longer enough. Lucas' digit rule in base m fails for every composite m: if p is a prime factor of m, then C(m, p) is not divisible by m, while its digit product is C(1, 0) · C(0, p) = 0.
What this page checks itself
A separate verification program recomputes everything with exact big integers: Lucas and Kummer for the primes 2 to 13 on every cell of the first 260 rows and on random cells up to row 4095; Glaisher's and Fine's counts; the exact counts (p(p + 1)/2)^j up to 2048 rows; the row test for every n below 260 with big integers and for every n below 2048 with digit sums; and the failure of the digit rule for 4, 6, 8, 9, 10 and 12. The table and the check marks on this page are computed live in your browser from the picture itself, not typed in.
Honesty note: nothing here is new, and nothing here predicts primes. These are classical theorems about the divisibility of binomial coefficients; the page only makes them visible. The slopes shown for composite moduli are observations in the stated range, not theorems.
References
- É. Lucas, Théorie des fonctions numériques simplement périodiques, American Journal of Mathematics 1 (1878), 184–240 and 289–321.
- E. E. Kummer, Über die Ergänzungssätze zu den allgemeinen Reciprocitätsgesetzen, Journal für die reine und angewandte Mathematik 44 (1852), 93–146.
- J. W. L. Glaisher, On the residue of a binomial-theorem coefficient with respect to a prime modulus, Quarterly Journal of Pure and Applied Mathematics 30 (1899), 150–156.
- N. J. Fine, Binomial coefficients modulo a prime, American Mathematical Monthly 54 (1947), 589–592.
- D. Singmaster, Notes on binomial coefficients III: any integer divides almost all binomial coefficients, Journal of the London Mathematical Society (2) 8 (1974), 555–560.
- S. Wolfram, Geometry of binomial coefficients, American Mathematical Monthly 91 (1984), 566–571.
- K. S. Davis and W. A. Webb, Lucas' theorem for prime powers, European Journal of Combinatorics 11 (1990), 229–233; A. Granville, Arithmetic properties of binomial coefficients I: binomial coefficients modulo prime powers, CMS Conference Proceedings 20 (1997), 253–275.
- M. Agrawal, N. Kayal and N. Saxena, PRIMES is in P, Annals of Mathematics 160 (2004), 781–793.
- OEIS A047999 · A001316 · A006046 · A083093 · A006047
- Independent verification program (available on request)