ExplorationsA fractal hiding inside the numbers from school
Pascal Modulo m
Build Pascal’s triangle from a top 1, placing 1 at each edge of a new row and adding neighbouring entries to fill the inside. Colour odd entries and leave even ones blank: the row 1, 2, 1 becomes coloured, blank, coloured. As you add rows, repeated triangular gaps form larger finite pieces of the Sierpiński gasket.
Interactive laboratory
Current view: The triangle
The triangle itself, printed as numbers while they fit and drawn as cells after.
| Row 0 | |
|---|---|
| Row 1 | |
| Row 2 | |
| Row 3 | |
| Row 4 | |
| Row 5 | |
| Row 6 | |
| Row 7 |
- entry
- one number of the triangle, printed
- working
- the two numbers above that were added to make it
- row
- one line of the triangle; row n has n + 1 entries
Each row is one line of the triangle, and row n has n + 1 entries. At the smallest sizes every entry is printed with the arithmetic that made it; past sixteen rows they become squares, filled where the entry survives division and blank where it does not. The blanks are the holes, and they are the whole picture.
8 rows of ordinary Pascal's triangle. Nothing has been reduced yet - every entry is the sum of the two above it. Pick a larger number of rows under Build it up, in the controls, to take the remainders.
- Modulus
- 2 · prime
- Rows
- 8
- Holes
- none yet
Try this
Row 12 is 1100 in binary. Without drawing it, how many of its entries are odd? Then check in the Counting view.
What is going on
Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.
| Row 0 | 11 |
|---|---|
| Row 1 | 1111 |
| Row 2 | 112011 |
| Row 3 | 11313111 |
| Row 4 | 1140604011 |
| Row 5 | 11511001005111 |
| Row 6 | 11601512001516011 |
| Row 7 | 11712113513512117111 |
| Row 8 | 11802805607005602808011 |
Now draw a filled square wherever the remainder is 1 and leave it blank wherever it is 0. Nine rows give the shape above; two hundred and fifty-six give the picture in the laboratory. Nothing else is done to it.
Row 7 came out entirely odd - 1, 7, 21, 35, 35, 21, 7, 1, not one of them even - and row 8 collapsed to a 1 at each end with seven zeroes between. Those two rows next to each other are the gasket in miniature: a solid base, and directly beneath it almost nothing. It happens again at rows 15 and 16, and at 31 and 32, and it never stops happening.
What you are seeing
A plain description of the process
Place a 1 at the top of a triangle. Each new row begins and ends with 1; every inside entry is the sum of the two entries immediately above it. This gives the rows 1; 1, 1; 1, 2, 1; and 1, 3, 3, 1, the beginning of Pascal's triangle.
Divide each entry by 2 and keep its remainder. An even entry leaves 0 and an odd entry leaves 1, so 1, 2, 1 becomes 1, 0, 1. Colour the 1s and leave the 0s blank.
As the triangle grows, repeated triangular gaps appear. Each displayed triangle is a finite stage of the pattern associated with the Sierpiński gasket, not the entire infinite fractal. Changing the divisor from 2 changes the remainders and the colours being compared.
Why it starts to make sense
Intuition, before any algebra
Watch what parity does to the addition rule. Odd + odd is even; odd + even is odd; even + even is even. So the parity of an entry depends only on the parities above it, and the triangle of 0s and 1s builds itself without ever consulting the actual coefficients.
That already explains why the pattern is possible - parity is self-contained, so nothing about the enormous numbers further down can interfere with it.
It does not explain why the pattern is a fractal. For that, notice which rows are entirely odd: 1, 3, 7, 15, 31. Each is one less than a power of two. A full row of 1s means the row beneath it is all 0s except at its ends - every interior entry is odd + odd - so a solid base is always followed by an empty row. And the structure that was built above that base then repeats, at twice the size, below it.
Solid rows at 2ᵏ − 1, doubling each time, is the gasket's construction, arrived at from the other direction.
The key idea
Read the row number in binary
Here is the whole thing in one sentence.
is odd exactly when the binary digits of are a subset of the binary digits of - when has a 1 nowhere that has a 0.
Try it. Row 4 is in binary. The only positions whose bits fit inside are and - that is and - so row 4 has exactly two odd entries, and indeed 1, 4, 6, 4, 1 is odd, even, even, even, odd.
Row 7 is . Every three-bit number fits inside , so every entry of row 7 is odd. All eight of them.
This is why the count of odd entries in row is , where is the number of 1s in : a set of elements has exactly subsets. And it is why the pattern is self-similar - "fits inside" is a condition on digit strings, so it repeats every time the string gets one place longer, which is every power of 2.
Formal statement
Precisely what is being claimed
Lucas' theorem. Let be prime, and write
with . Then
Two consequences, which are what this page draws:
- if and only if for at least one . (One such place makes a factor .)
- Taking : the number of odd entries in row is , where counts the 1s in the binary expansion of .
Note carefully what is not claimed. Lucas requires prime. There is no equally simple statement for composite moduli, and this page does not pretend otherwise.
Proof
Complete, not a sketch
Work in . The binomial theorem gives
and for the coefficient has a factor of in its numerator and none in its denominator, since is prime and . So every middle term vanishes modulo :
Raising repeatedly, . Now expand in base and split the polynomial along its digits:
Expand each factor. The -th contributes for some . Because base- representations are unique, each exponent arises from exactly one choice of digits - so collecting the coefficient of on both sides gives
The two consequences follow directly. For the first: when , and otherwise it is a binomial coefficient of numbers smaller than , hence not divisible by the prime ; a product of non-multiples of a prime is a non-multiple. For the second: at each digit factor is or , so the entry is odd exactly when 's bits sit inside 's, and the number of such is .
This is what a proof buys you. No amount of drawing rows establishes the claim for row 1,000,000; three lines of polynomial algebra establish it for every row at once. Every other exploration in this guide is missing exactly this, and it is worth feeling the difference.
Limits and frontier
Where this page stops being able to help
The fractal is a limit, and the screen is not. What this laboratory draws is a finite triangle - at most 512 rows. The Sierpiński gasket is what the parity pattern approaches when the drawing is scaled to a fixed size and the number of rows grows without bound. Every finite picture here is an approximation to it, and the resemblance at 256 rows is not evidence for the limit; the proof in layer 5 is.
Composite moduli are genuinely harder, not merely untidy. Try modulus 6 and the nesting degrades visibly. That is not a rendering artefact: Lucas needs a prime, and there is no comparably simple digit criterion for a composite. The general theory - Kummer's carry-counting result, and the extensions to prime powers - is real mathematics and substantially more involved than anything above. The claim on this page about composites is deliberately marked observed rather than proved, and its scope names the 512 rows it was measured over: at that size modulo 2 leaves 85.0% of the entries as holes and modulo 6 leaves 70.3%, and neither number is a theorem.
What this page is for. It is the control case in this collection. Gilbreath's left edge looks every bit as convincing as the gasket does and remains an open problem; the happy numbers are settled, but by exhausting a finite space rather than by an argument. Here the picture and the proof are the same object, and holding all three in mind is the most useful thing this guide can give you - because from the outside, a pattern with a proof behind it and a pattern without one look exactly alike.
What is actually established
Every statement on this page, with its status, its exact scope, and the date that status was last checked.
For a prime p, C(n, k) mod p is the product over base-p digit places of C(nᵢ, kᵢ) mod p.
- Scope
- All non-negative integers n and k, and all primes p.
- Why
- Lucas’ theorem, 1878. The usual proof compares coefficients in (1 + x)ⁿ modulo p, where (1 + x)^p ≡ 1 + x^p, so the polynomial factors along the base-p digits of n and the coefficient of x^k factors with it.
- Status checked
C(n, k) is divisible by a prime p exactly when some base-p digit of k exceeds the matching digit of n.
- Scope
- All non-negative integers n and k with k ≤ n, and all primes p.
- Why
- Immediate from Lucas: a digit place with kᵢ > nᵢ contributes C(nᵢ, kᵢ) = 0, and a product with a zero factor is zero. Conversely, if every kᵢ ≤ nᵢ then every factor is a binomial coefficient of numbers below p, so none is divisible by p and neither is the product. This is the statement the picture is a picture of.
- Status checked
The number of odd entries in row n of Pascal’s triangle is 2 raised to the number of 1s in the binary expansion of n.
- Scope
- Every row n ≥ 0.
- Why
- Lucas at p = 2: the entry C(n, k) is odd exactly when every binary digit of k is at most the matching digit of n - that is, when k’s bits are a subset of n’s. A set with r elements has 2ʳ subsets.
- Status checked
Scaled to a fixed size, the parity triangle converges to the Sierpiński gasket as the number of rows grows.
- Scope
- The limit of the parity pattern under repeated halving; not a statement about any finite drawing.
- Why
- The subset condition above is self-similar under doubling: the odd entries of the first 2ᵏ rows repeat, in three copies, in the first 2ᵏ⁺¹. That is exactly the gasket’s construction. What is on screen here is always a finite approximation - the fractal is the limit, and no drawing is it.
- Status checked
For a composite modulus the pattern is coarser and does not nest in the same way.
- Scope
- The moduli this laboratory offers, drawn to at most 512 rows. At 512 rows modulo 2 leaves 85.0% of entries as holes, and modulo 6 leaves 70.3%.
- Why
- Deliberately not stated as a theorem. Lucas needs a prime, and the extensions that handle prime powers and composites are substantially more complicated - so the honest statement here is about what this page draws, not about all moduli. Granville’s survey is where the general case lives.
- Computation (exact)
- Exact integer arithmetic in remainders, over the first 512 rows - 131,328 entries - computed in your browser and cross-checked in the test suite against Lucas’ theorem evaluated independently for every prime modulus on offer. Algorithm pascal-1.
- Status checked
Sources
Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.
- Édouard Lucas, Théorie des fonctions numériques simplement périodiques, American Journal of Mathematics 1, 1878. Link
The classical reference for the digit-by-digit congruence for binomial coefficients modulo a prime.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
Journal archive identifies Lucas, title and 1878 publication.
- Ernst Kummer, Über die Ergänzungssätze zu den allgemeinen Reciprocitätsgesetzen, Journal für die reine und angewandte Mathematik 44, pp. 93–146, 1852. Link
The companion result: the exact power of p dividing C(n, k) is the number of carries when k and n − k are added in base p. It explains the same holes from the other side, and is the sharper statement of the two.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
Publisher distinguishes the 1852 issue from the 2009 digitisation date.
- Andrew Granville, Arithmetic properties of binomial coefficients, Organic Mathematics (CMS Conference Proceedings 20), 1997. Link
A survey of what is known about binomial coefficients modulo prime powers, including the extensions of Lucas that composite moduli need. Cited here for the boundary of the clean statement rather than for the clean statement itself.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
University-hosted proceedings article confirms author and title.
- A047999 - Sierpiński’s gasket: Pascal’s triangle mod 2, The On-Line Encyclopedia of Integer Sequences. Link
The parity triangle as a sequence, with references. Used to check the first rows of the field built here against a published listing.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Checked the sequence identifier, definition and displayed initial terms on the database entry.
- A001316 - Gould’s sequence: number of odd entries in row n of Pascal’s triangle, The On-Line Encyclopedia of Integer Sequences. Link
The count this page predicts and then verifies: 2 raised to the number of 1 bits in n. The test suite checks 200 rows against the closed form.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Checked the sequence identifier, definition and displayed initial terms on the database entry.
Related by mechanism
Connected by how they work, not by sharing a topic label.