Two primes where Fermat holds twice
Worth reading first: An order that proves a prime · Necklaces that prove a theorem.
Fermat’s little theorem says that is divisible by for every odd prime . For the number is 15, divisible by 5 and not by 25. For it is 63, divisible by 7 and not by 49. For it is 1023, divisible by 11 and not by 121. It would be natural to guess that never divides it, and for every odd prime below 1093 the guess is right.
At it is wrong. Waldemar Meissner found in 1913 that is divisible by . N. G. W. H. Beeger found the second example, 3511, in 1922. A century of searching since, carried by 2022 to every prime below about , has found no third.
The primes where divides are the Wieferich primes, after Arthur Wieferich, who showed in 1909 that they are exactly where a certain case of Fermat’s last theorem could fail. Between 1093 and 3511 and beyond, the picture is noise.
The quotient that Fermat’s theorem leaves
Fermat’s theorem makes a whole number, the Fermat quotient . Its remainder on division by is a number between 0 and , and divides exactly when that remainder is 0.
Nothing in the theorem constrains the remainder. The figure plots it, divided by so that every prime gets a number between 0 and 1, for all 549 odd primes up to 4,000. The points fill the square evenly, with no drift, no preference for small values and no visible structure. The two that sit on the axis are the two Wieferich primes, and they look like accidents in a field of accidents.
That evenness is the basis of every estimate about Wieferich primes, and it is only a heuristic. If the remainder behaved like a random choice from possibilities, a given prime would be Wieferich with probability . Nothing proves that it behaves that way; the figure is evidence that, for these primes, nothing obviously prevents it.
The quotient can be computed without the huge number : compute modulo by repeated squaring, subtract 1, and divide by . For up to a few thousand the numbers stay below , well inside the range where ordinary arithmetic is exact. The figure checks, at every prime, that Fermat’s theorem holds before trusting the quotient.
Another base, other accidents
Nothing about the phenomenon is specific to 2.
For base 3 the same scatter appears, and the first zero is at 11: . The next is 1,006,003, far beyond the figure. Base 3 has its own Wieferich primes, unrelated to base 2’s, and they are just as sparse and just as patternless. The two scatters are not copies of each other either: at a given prime the quotients for base 2 and base 3 are unrelated numbers, and a prime that is ordinary for one base can be exceptional for another. What they share is the one thing Fermat’s theorem guarantees and nothing more.
Across six bases the search below 200,000 finds a scattering: 1093 and 3511 for base 2, 11 for base 3, 2, 20771 and 40487 for base 5, 5 for base 7, 3 and 487 for base 10, and 71 for base 11. There is no evident rule, no relation between the bases, and no tendency for the primes to cluster. The small ones are small only because small primes have larger chances: at the chance is a fifth, and base 7 duly obliges.
What the extra divisibility does to an order
The Wieferich condition has a cleaner description in terms of the order of 2, the length of the cycle its powers make.
Modulo the powers of 2 cycle with some period dividing . Modulo the period is a multiple of — reducing mod must still cycle — and divides . It turns out to be either or , and it is exactly when , which is exactly the Wieferich condition. So for every ordinary prime, the cycle modulo is times longer; for a Wieferich prime it is not longer at all.
That is a statement about lifting. Most facts that hold modulo can be lifted to , and so on by a standard procedure — Hensel’s lemma — and the lift usually changes things by a factor of at each stage. The Wieferich primes are where the first lift of the powers of 2 is degenerate. For 1093 the order of 2 is 364 modulo and still 364 modulo . For 3511 it is 1755 at both levels. For every other prime in the figure the cycle modulo is times the cycle modulo , which is why the points line up on the diagonal so exactly: the ratio is not approximately but exactly , and the figure computes it as such, by testing whether the shorter cycle already closes modulo .
Fermat’s last theorem, a century early
Wieferich’s interest in 1909 was not the primes themselves but what they excluded. Fermat’s last theorem says has no solutions in positive whole numbers for any odd prime . Its “first case” is the claim for solutions in which divides none of , , .
Wieferich proved that if the first case fails for a prime , then is a Wieferich prime. In 1909 no Wieferich prime was known at all — 1093 was found four years later — so the theorem proved the first case for every prime that anyone checked, and the checks were cheap. Later work added base 3, base 5 and many more: a first-case counterexample at would force to be Wieferich for every base up to 89, and no prime is. So the first case was settled for enormous ranges of long before Andrew Wiles proved the whole theorem in 1995 by entirely different means.
The connection is a relic now, but it was the reason Wieferich primes were searched for so hard. Every prime cleared by the search was a prime for which a case of Fermat’s last theorem was known to hold, and the search was a way to approach the theorem one exponent at a time.
Relatives: Wilson primes and Wall–Sun–Sun primes
The Wieferich primes are one of a family of “second-order” questions, each asking whether a congruence that holds modulo by some classical theorem happens to hold modulo .
Wilson’s theorem says is divisible by for every prime — the product of all the nonzero residues is , because every residue pairs with its inverse except and , a fact the arithmetic of a clock makes visible. The primes for which divides it are the Wilson primes, and only three are known: 5, 13 and 563, the last found in 1955, with searches since reaching beyond . The same one-in- heuristic applies, and gives the same slowly growing expectation.
For the Fibonacci numbers, divides for every prime other than 5, where the sign depends on modulo 5. A Wall–Sun–Sun prime is one where divides it, and none is known at all, in searches past . Zhi-Hong Sun and Zhi-Wei Sun showed in 1992 that a first-case counterexample to Fermat’s last theorem at would make one of these as well — the same role Wieferich primes played, for a different sequence.
The pattern across the family is the same. A theorem supplies divisibility by ; the extra factor of is a coin with a one-in- chance of landing; the expected number is a sum of that barely grows; and the known examples are a handful of small primes where a coin with a large chance happened to land, followed by silence.
What the chance predicts
If each odd prime is Wieferich independently with probability , the expected number of Wieferich primes below is the sum of over odd primes up to .
That sum grows without bound, but only like — the logarithm of the logarithm — as Mertens showed for the reciprocals of the primes. By it has reached about 3.6. The heuristic therefore predicts infinitely many Wieferich primes, and predicts that finding the next few requires searching ranges of exponentially exponential size: to expect one more beyond the current search, the bound has to be raised from to something like .
So the drought is not evidence against the heuristic. Two found where 3.6 are expected is well within what a random count allows, and the flat stretch in the figure — no new prime for a factor of — is a stretch over which the expected count grows by only about one and a half. Small cases lie in number theory in both directions, and here the lie would be to read a century without a third example as a sign that there is none. A quantity growing like is almost invisible to computation: itself reaches 3 at about and 4 only at about , so the whole of the searching done since 1913, from a thousand to , has moved it from about 1.9 to about 3.8, and no feasible search will move it by more than a unit or so. The same slowness hides how rare sums of two squares become, whose density falls to nothing at a rate no computation could notice, and it is the rate at which the sieve of Eratosthenes fails to finish — the sum of that diverges, but only just.
What the heuristic cannot supply is a proof that Wieferich primes keep coming. Divergence of the expected count is a statement about a model in which the quotients are independent random numbers, and the actual quotients are determined by the arithmetic of powers of 2 in a way nobody has managed to control. The model says infinitely many; the mathematics says nothing.
Two bases at once
A prime could be Wieferich for base 2 and base 3 simultaneously. Neither 1093 nor 3511 is Wieferich for base 3, and neither 11 nor 1,006,003 is Wieferich for base 2, and no prime is known that satisfies both conditions. On the heuristic, a prime satisfies both with probability , and the sum of over all primes converges — to about 0.45 — so the heuristic predicts that such primes are finitely many, and probably none at all beyond the small range already searched.
That difference is instructive. A single condition with chance gives a divergent sum and infinitely many expected examples, however sparse; two independent conditions give a convergent sum and a finite expectation. The same arithmetic separates the Wieferich question from, say, primes where divides , of which the heuristic predicts only finitely many and none are known. Neither 1093 nor 3511 has a third factor: is divisible by and not by . Where the heuristic says the expected count converges, the searches find nothing; where it says the count diverges, they find a handful. The heuristic has never been caught being wrong about which kind of question is which.
What the figures cannot show
Every figure is a finite search, and the Wieferich primes are a question about all primes. The scatter of quotients looks random for primes to 4,000, and the heuristic depends on that randomness continuing; no one can prove it does, and there are other quotient-like quantities in number theory that look random for a long time and then reveal structure.
The expected-count curve is a heuristic plotted, not a theorem. It uses the known asymptotic for the sum of reciprocals of the primes, which is proved, and the assumption that each prime is Wieferich with chance , which is not. The “found” staircase stops at the limit of the searches; beyond nothing is known either way.
And the table of other bases shows the Wieferich primes below 200,000 only. Several bases have further known ones far beyond the table — base 3 at 1,006,003, base 7 at 491,531, base 10 at 56,598,313 — and some bases have none known at all. The quotient figures stop at 4,000 because beyond that the squares of the primes outgrow the exact arithmetic the figures use; the table of bases switches to arbitrarily large whole numbers to go further, and searches beyond it use the same method on much faster machines. None of them changes the picture, which is a scatter with nothing in it but chance.
Still open: more, or infinitely many, or infinitely many of the other kind
It is not known whether there are infinitely many Wieferich primes. It is also not known whether there are infinitely many non-Wieferich primes — primes for which does not divide — although every prime anyone has tested except two is one.
That second gap is the stranger. The non-Wieferich primes are, by every measure, almost all primes, and yet no proof shows there are infinitely many. Joseph Silverman proved in 1988 that there are infinitely many assuming the abc conjecture, a deep statement about the prime factors of , and . Without it the question is open. A property shared by all but two of the primes below cannot be shown to hold for infinitely many of them, which is a precise measure of how little is known about the digits of beyond what Fermat’s theorem says.
The abc conjecture itself was claimed proved by Shinichi Mochizuki in 2012, in a series of papers whose argument most specialists have not accepted, and whose status remains disputed. If a proof were accepted, the infinitude of non-Wieferich primes would follow immediately. Until then, the statement that almost every prime is not Wieferich — true of every prime below with two exceptions — is known only conditionally.
Twice, by accident
Fermat’s theorem guarantees one factor of in . A second factor is an extra coincidence, a one-in- event if the leftover quotient is as random as it looks, and the searches have found it twice: at 1093, in 1913, and at 3511, in 1922. Every other prime to has the single factor and no more.
The numbers fit a random model that predicts infinitely many such primes, arriving at a rate so slow that a third may lie beyond any search that will ever be run. They also fit, as far as anyone can prove, a world in which there are only two. And the opposite statement — that infinitely many primes have only the one factor — is equally beyond proof. Between the theorem Fermat stated and the question it leaves, a single extra power of marks the edge of what number theory can say about .
The necklaces that proved Fermat’s theorem counted strings of beads round a loop and found them falling into rings of , which forced the one factor. No counting argument of that kind gives the second, and the Fermat quotient is what is left over when the counting stops — a residue that every known method sees as noise. That the noise has landed on zero twice, and that nobody can say whether it will again, is a fair summary of how the theorem that the exponent is smaller than Euler’s and the theorems around it end: with a count that is exact, and a remainder that is not understood.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- Every class, and in equal shares — both name modular arithmetic, prime
- Every element is a power of one of them — both name fermats little theorem, modular arithmetic
- Infinitely many of one kind — both name modular arithmetic, prime
- Solutions that come in multiples of p — both name fermats little theorem, modular arithmetic
- Three in a row on the number line — both name fermats little theorem, modular arithmetic
- Which infinitudes are proved — both name heuristic, prime
Named objects
A dashed tag is an object no other essay names yet.
Fermat last theoremFermats little theoremHeuristicModular arithmeticOrder of an elementPrime