The Fermat Lattice
This grid is a multiplication table wearing a disguise. Instead of listing a product by its two factors, list it by the midpoint and the imbalance. A cell at position (a, b) holds the number v = a² − b², which always equals (a − b) × (a + b). So a is the average of the two factors and b measures how far apart they are. Every odd product of two odd numbers appears exactly once. The default coloring sorts cells into four families by whether each factor is prime, and the picture that results is not random-looking at all.
Once you know what the lines mean, the famous unsolved problems of number theory are sitting right there on the grid. The rows are prime gaps: row 1 contains exactly the twin primes, so scroll along it and you will find 3 and 5 at a = 4, then 5 and 7, then 11 and 13, 17 and 19, 29 and 31. Whether that row goes on forever is the twin prime conjecture, still open. The columns are Goldbach: column 25 lists every way to write 50 as two odd primes, which is 19 + 31, 13 + 37, 7 + 43, and 3 + 47. Whether every column has at least one entry is Goldbach's conjecture, unsolved since 1742, and you can scan columns looking for an empty one. The diagonal one step in from the edge is the list of primes themselves. Turning on "Sophie Germain" paints the line a = 3b − 1, which collects the pairs where a prime and its double-plus-one are both prime: 3 and 7, 5 and 11, 11 and 23, 23 and 47.
The "sieve" control is the most satisfying thing to play with. Turn it up through 3, 5, 7, 11, 13, and cells with small prime factors fade toward the paper, leaving only the survivors standing. It is worth predicting before you look. Most people guess that turning on 3 removes about a third. It removes more than half, because both factors have to dodge 3 and they dodge it independently, so the fraction surviving is the square of what you would first guess. Watching that happen is a better argument than the algebra.
Last, type N=3599 into the "go to" box. The page jumps to the most balanced way of splitting 3599 and draws the curve through every other factor pair of the same number. This is Fermat's factorization method as a picture: he searched along a row like this one, looking for a square. The distance b from the diagonal tells you how vulnerable a number is to that attack, and a number whose b is small compared to the fourth root of v is precisely what a modern cryptographer calls a weak key. Try a few large numbers of your own and see which ones sit dangerously close to the diagonal.
Portrait of Pierre de Fermat. Public Domain.
Residual Matrix
Pick a number n and a smaller number d. Now walk up the multiples of d toward n, but only step on every other multiple: the ones whose multiplier is odd if d is odd, and even if d is even. Stop at the last such multiple that does not pass n. Whatever gap is left over is the number printed in the cell. The rows of this grid are n, the columns are d (labeled as 2d across the top), and the whole 160,000-cell block is just that one instruction repeated.
That strange parity rule is doing something specific. If d and its partner Q are both odd or both even, then their product can be written as a difference of two squares: d × Q = x² − y², where x is the average of d and Q and y is half their difference. So a cell reading zero is announcing a real factorization of n, found the way Pierre de Fermat found factorizations in the 1640s. Click any cell and press "Show working" to see the whole calculation laid out, including the two squares.
The single best thing to hunt for is how empty the prime rows are. On any odd row, the zeros sit exactly at the divisors of n and nowhere else, so an odd prime has precisely two zeros in its entire row, one at the far left and one at d = n. Scroll down an odd prime row like 101 and it is a desert. Then look at row 105, which is 3 × 5 × 7, and count eight zeros. Primes are visibly the loneliest rows in the picture. Perfect squares go the other way: every square lands on a zero at d equal to its square root, so type 144, 24 into the "go to" box and watch it happen.
Two more things to play with. The "shapes" box accepts entries like 3, 5, 1/3, or D5, and paints whole curved families of zeros across the block; n = 3d² is zero at every single point, and so is its mirror curve, which means one factorization is being read from two directions at once. And to see Fermat's method actually crack a number, type 3599, 118 into "go to". The cell reads zero, and the panel tells you why: 3599 = 60² − 1² = 59 × 61. A four-digit number factored in one glance at one square.
Power Residue Matrix
This one asks a single question over and over: take a number k, raise it to a power n, divide by a prime p, and keep the remainder. Rows are the base k, columns are the prime p, and the exponent is the third dimension, stepped with the arrows or with the [ and ] keys. Exponent 2 gives you the squares, exponent 3 the cubes, and so on. The striking thing is how little of the grid is actually used: raising to a power collapses the possibilities dramatically, and how much it collapses depends on an interaction between n and p that you can watch directly.
Start by stepping the exponent between 2 and 3 while watching any single column. At even exponents the column is a mirror, reading the same from top to bottom as from bottom to top, because k and p − k are negatives of each other and a negative disappears when you square it. At odd exponents the mirror flips into its opposite. Then push the exponent up to 12 and look at the column for 13: it goes solid 1, every entry. That is Fermat's little theorem, one of the cornerstone results of the subject, appearing as a stripe of ones. Any column goes solid the moment the exponent reaches a multiple of p − 1, so at exponent 6 the columns for 2, 3, and 7 are already lit, and the pattern of which columns light up when is a divisibility question you can read off the screen.
Count the distinct values in a column and you get exactly (p − 1) divided by the greatest common divisor of n and p − 1. At exponent 2 that means half of all possibilities survive, and those survivors are the quadratic residues, one of the oldest objects in number theory. The "coset of k" view colors the rows by which family they fall into, and "order of k" draws a heat map of how long each base takes to cycle back to 1. Turn on "primitive roots" to highlight the bases that generate everything else, and take a moment to notice how unpredictably scattered they are.
For a real discovery you can make yourself, look at the primitive roots in two different columns. In column 13, they are 2, 6, 7, and 11, and they pair up: 11 is 13 − 2, and 7 is 13 − 6. In column 7 they are 3 and 5, and neither 7 − 3 = 4 nor 7 − 5 = 2 is a primitive root. The pairing works for every prime that is one more than a multiple of 4, and fails for every single primitive root of every prime that is three more. There is no in-between column anywhere. This page was built partly to check a claim in an earlier writeup, which had this dichotomy exactly backwards; the smallest counterexample is the column for 7, sitting near the top left corner where anyone could have seen it.
Hyper Matrix
Look back at the rule for the first grid and you will notice the number 2 is hiding in exactly one place, in the odd-or-even parity condition. That is the only ingredient worth replacing. Swap 2 for 3, or 5, or 47, and you get a different grid with the same shape. This page stacks all of those grids into one object and gives you a slider to step through them. Each slice is a complete matrix in its own right, and the prime you have selected is the only thing that changes.
On the default setting, a cell is zero when d divides n and d is forced to leave at least one factor of the chosen prime behind. So on rows where the prime does not divide n at all, the condition is just plain divisibility, and on rows where it does, d has to give up some of it. The clearest experiment on the whole page is to watch the zero count in the status bar while you step the prime upward: 1,852 at p = 2, then 1,969, 2,150, 2,245, 2,333, and 2,360 by p = 13. The filter gets weaker as the prime gets bigger, and the count climbs toward the total number of divisor cells without ever reaching it. The formula behind that climb is 1 − 1/p + 1/p², and you are watching it converge to 1.
The "rule" switch is the honest part of this page. It flips between the definition above and the Fermat definition from the first grid, which sound like the same thing and are not. At p = 2 they differ by 616 cells out of the block, mostly the entire leftmost column on even rows. Two reasonable-sounding descriptions of one object, disagreeing by a third. Flip the switch a few times and watch which cells appear and vanish.
For visual patterns, try "prime stack," which shades each cell by how many of the six small primes it fails. The long diagonal where d = n comes out loudest because it fails every prime dividing n at once. Then try "p-tower," which shades rows by how many times the prime divides n; at p = 2 you get a clean binary staircase where half the rows are on level zero, a quarter on level one, and so on. Finally, click any cell and turn on "rays": the two diagonals through your cell light up, and the panel predicts how many zeros lie on each one, using nothing but a count of divisors. You can count them by hand and check.
Hyper Matrix at Higher Rank
The previous page added a coordinate by changing which prime does the filtering. This one adds coordinates by using more than one divisor. A cell is now a whole list, (n, d₁, d₂, d₃), and it counts as a member only if every single d in the list divides n and every one of them leaves a factor of each chosen prime behind. You control the rank with a switch (one, two, or three divisors) and set the extra divisors with steppers. The checkbox row labeled S decides which primes get to do the filtering.
The experiment this page exists for takes about ten seconds. Set the rank to 2, then push d₂ up and down. Whole rows blink out of existence, and the pale blue cells mark the ones that would still qualify if you only had one divisor. Here is the thing to notice: the rows that survive keep their pattern completely unchanged. Adding a second divisor never rearranges the first one, it only deletes rows wholesale. That is a picture of a real theorem, that the count for r divisors is just the one-divisor count raised to the power r.
You can verify the counting yourself. Click into row 360, which factors as 2³ × 3² × 5. It has 24 divisors in total. Turn on the primes 2 and 3 in S and the count drops to 12, because the exponent of 2 contributes a factor of three-quarters and the exponent of 3 contributes two-thirds: 24 × ¾ × ⅔ = 12. The panel recomputes this against a brute-force check every time you click, and puts a tick or a cross next to it. Toggle the primes in S one at a time and watch the density fall in a predictable, multiplying way.
There is also a genuine research payoff visible here, and it is a good lesson in why people build pictures of formulas. The written-up version of this work predicted that the totals grow like X times a power of log X, with the power equal to the rank. The grid disagrees. The correct power is 2^r − 1, which happens to equal r when r is 1, which is why nobody caught it. The panel prints both the corrected law and the original claim side by side. Set the rank to 3 and the gap is large: 7 versus 3.







