Extending Babbage's (Non-)Primality Tests
Jonathan Sondow

TL;DR
This paper revisits Charles Babbage's early 19th-century primality test, extends it to identify the least prime factor, and explores related congruences, connecting historical and modern number theory insights.
Contribution
It introduces an extension of Babbage's primality criterion to find the least prime factor and proves a partial converse, enriching the understanding of primality tests.
Findings
Extended Babbage's primality test to least-prime-factor detection
Proved a partial converse of Babbage's non-primality test
Connected historical and modern number theory concepts
Abstract
We recall Charles Babbage's 1819 criterion for primality, based on simultaneous congruences for binomial coefficients, and extend it to a least-prime-factor test. We also prove a partial converse of his non-primality test, based on a single congruence. Two problems are posed. Along the way we encounter Bachet, Bernoulli, Bezout, Euler, Fermat, Kummer, Lagrange, Lucas, Vandermonde, Waring, Wilson, Wolstenholme, and several contemporary mathematicians.
Click any figure to enlarge with its caption.
Figure 1Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsHistory and Theory of Mathematics
11institutetext: 209 West 97th Street, New York, NY 10025 [email protected]
Extending Babbage’s (Non-)Primality Tests
Jonathan Sondow
Abstract
We recall Charles Babbage’s criterion for primality, based on simultaneous congruences for binomial coefficients, and extend it to a least-prime-factor test. We also prove a partial converse of his non-primality test, based on a single congruence. Two problems are posed. Along the way we encounter Bachet, Bernoulli, Bézout, Euler, Fermat, Kummer, Lagrange, Lucas, Vandermonde, Waring, Wilson, Wolstenholme, and several contemporary mathematicians.
1 Introduction
Charles Babbage was an English mathematician, philosopher, inventor, mechanical engineer, and “irascible genius” who pioneered computing machines babbagebio ; beyer ; grabiner ; moseley ; mactutor ; odonnell . Although he held the Lucasian Chair of Mathematics at Cambridge University from to , during that period he never resided in Cambridge or delivered a lecture blackwood , (dubbey, , p. ).
Charles Babbage (1791–1871)
In he published his only work on number theory, a short paper babbage that begins:
The singular theorem of Wilson respecting Prime Numbers, which was first published by Waring in his Meditationes Analyticae (waring, , p. 218), and to which neither himself nor its author could supply the demonstration, excited the attention of the most celebrated analysts of the continent, and to the labors of Lagrange lagrange and Euler we are indebted for several modes of proof
Babbage formulated Wilson’s theorem as a criterion for primality: an integer is a prime if and only if . (For a modern proof, see Moll (moll, , p. 66).) He then introduced several such criteria, involving congruences for binomial coefficients (see Granville (granville, , Sections 1 and 4)). However, some of his claims were unproven or even wrong (as Dubbey points out in (dubbey, , pp. 139–141)). One of his valid results is a necessary and sufficient condition for primality, based on a number of simultaneous congruences. Henceforth let denote an integer.
Theorem 1.1 (Babbage’s Primality Test).
An integer is a prime if and only if
[TABLE]
for all satisfying
This is of only theoretical interest, the test being slower than trial division.
The “only if” part is an immediate consequence of the beautiful theorem of Lucas lucas (see fine ; granville ; mestrovic0 ; mestrovic2 and (moll, , p. 70)), which asserts that if is a prime and the non-negative integers and are written in base so that for all , then
[TABLE]
(Here the convention is that if .) The congruence (1) follows if , for then all the binomial coefficients formed on the right-hand side of (2) are of the form except the last one, which is
However, the theorem was not available to Babbage, because when it was published in he had been dead for seven years.
Lucas’s theorem implies more generally that for a prime and a power of the congruences
[TABLE]
hold. A converse was proven in : Meštrović’s theorem mestrovic2 states that if and are integers such that (3) holds, then is a prime and is a power of To begin the proof, Meštrović noted that for the hypothesis gives
[TABLE]
The rest of the proof involves combinatorial congruences modulo prime powers.
As Meštrović pointed out, “the ‘if’ part of Theorem 1.1 is an immediate consequence of [his theorem] (supposing a priori [that ]). Accordingly, [his theorem] may be considered as a generalization of Babbage’s criterion for primality.”
Here we offer another generalization of Babbage’s primality test.
Theorem 1.2 (Least-Prime-Factor Test).
The least prime factor of an integer is the smallest natural number satisfying
[TABLE]
For that value of the least non-negative residue of modulo is
The proof is given in Section 2.
Babbage’s primality test is an easy corollary of the least-prime-factor test. Indeed, Theorem 1.2 implies a sharp version of Theorem 1.1 noticed by Granville granville in
Corollary 1 (Sharp Babbage Primality Test).
Theorem 1.1 remains true if the range for is shortened to
Proof.
An integer is a prime if and only if its least prime factor exceeds The corollary follows by setting in Theorem 1.2.
□
To see that Corollary 1 is sharp in that the range for cannot be further shortened to , let be any prime and set . Then is not a prime, but the least-prime-factor test with and implies (1) when .
Problem 1.
Since the “if” part of Babbage’s primality test is a consequence both of Meštrović’s theorem and of the least-prime-factor test, one may ask, Is there a common generalization of Meštrović’s theorem and Theorem 1.2? (Note, though, that the modulus in the former is while that in the latter is )
Actually, the incongruence (4) holds more generally if the least prime factor is replaced with any prime factor . The following extension of the least-prime-factor test is proven in Section 2. See also Sondow (sondow, , Part (a)).
Theorem 1.3.
* Given a positive integer and a prime factor , we have*
[TABLE]
* If in addition but , where , then*
[TABLE]
Part () is clearly equivalent to the statement that if divides and , then is composite. As an example, for and we have
[TABLE]
The sequence of integers for which some integer (necessarily composite) satisfies
[TABLE]
begins (oeis, , Seq. A290040)
[TABLE]
and the sequence of smallest such divisors is, respectively, (oeis, , Seq. A290041)
[TABLE]
Problem 2.
Does Theorem 1.3 extend to prime power factors, i.e., does (5) also hold when is replaced with , where and ? In particular, in the sequence (8), is any term a prime power?
See (sondow, , Part (c)).
Babbage also claimed a necessary and sufficient condition for primality based on a single congruence. But he proved only necessity, so we call it a test for non-primality.
Theorem 1.4 (Babbage’s Non-Primality Test).
An integer is composite if
[TABLE]
Our version of his proof is given in Section 3.
Not only did Babbage not prove the claimed converse, but in fact it is false. Indeed, the numbers and are composite but do not satisfy (9), where and are primes.
Here (indicated by Selfridge and Pollack in ) and (discovered by Crandall, Ernvall and Metsänkylä in ) are Wolstenholme primes, so called by Mcintosh mcintosh because, while Wolstenholme’s theorem wolstenholme (see granville ; mestrovic ; tw and (moll, , p. 73)) of guarantees that every prime satisfies
[TABLE]
in fact and satisfy the congruence in (10) modulo , not just (see Guy (guy, , p. 131) and Ribenboim (ribenboim, , p. 23)).
Note that (10) strengthens Babbage’s non-primality test, as Theorem 1.4 is equivalent to the statement that the congruence in (10) holds modulo for any prime .
In their solutions to a problem by Segal in the Monthly, Brinkmann sb and Johnson sj made Babbage’s and Wolstenholme’s theorems more precise by showing that every prime satisfies the congruences
[TABLE]
where denotes the th Bernoulli number, a rational number. (See also Gardiner gardiner and Mcintosh mcintosh .) Thus, a prime is a Wolstenholme prime if and only if . (The congruence means that divides the numerator of .) In that case, the square of that prime, say , is composite but must satisfy
[TABLE]
thereby providing a counterexample to the converse of Babbage’s non-primality test.
Johnson sj commented that “interest in [Wolstenholme primes] arises from the fact that in , Kummer proved that the first case of [Fermat’s Last Theorem] is true for all prime exponents such that .”
We have seen that the converse of Babbage’s non-primality test is false. The converse of Wolstenholme’s theorem is the statement that if is composite, then (10) does not hold. It is not known whether this is generally true. A proof that it is true for even positive integers was outlined by Trevisan and Weber tw in . In Section 3, we fill in some details omitted from their argument and extend it to prove the following stronger result.
Theorem 1.5 (Converse of Babbage’s Non-Primality Test for Even Numbers).
If a positive integer is even, then
[TABLE]
2 Proofs of the least-prime-factor test and its extension
We prove Theorems 1.2 and 1.3. The arguments use only mathematics available in Babbage’s time.
Theorem 1.2.
As is the smallest prime factor of if then and are coprime. In that case, Bézout’s identity (proven in by Bachet in a book with the charming title Pleasant and Delectable Problems (bachet, , p. 18, Proposition XVIII)—see (chabert, , Section 4.3)) gives integers and with . Multiplying Bézout’s equation by the number yields
[TABLE]
so if Now, for , Vandermonde’s convolution vandermonde (see (moll, , p. 164)) of gives
[TABLE]
(To see the equality, equate the coefficients of in the expansions of and ) Thus, we arrive at the congruences
[TABLE]
On the other hand, from the identity
[TABLE]
(to prove it, use factorials), the congruence (12) for , the integrality of , and the inequality (as is a prime), we deduce that
[TABLE]
Together with (12), this implies the least-prime-factor test.
□
Theorem 1.3.
It suffices to prove (ii). Set
[TABLE]
Note that
[TABLE]
since . Bézout’s identity gives integers and with . When , multiplying Bézout’s equation by yields
[TABLE]
with an integer, so . Dividing by gives
[TABLE]
Combining this with (13) and Vandermonde’s convolution, we get
[TABLE]
As , we have . Now, (14) and (15) imply (6), as required.
□
3 Proofs of Babbage’s non-primality test and its converse for even numbers
The following proof is close to the one Babbage gave.
Theorem 1.4.
Suppose on the contrary that is prime. If we have , then divides the numerator of but not the denominator, so . Thus, by (13) and a famous case of Vandermonde’s convolution,
[TABLE]
But as is odd, (16) contradicts (9). Therefore, is composite.
□
Before giving the proof of Theorem 1.5, we establish two lemmas. For any positive integer let denote the highest power of that divides
Lemma 1.
If are integers satisfying then the formula holds.
Proof.
Let with odd. Note that if . (Proof. Write where and is odd. Then is also odd, so ) The logarithmic formula then implies that when the exponent of the highest power of that divides the product
[TABLE]
is , so . As , this proves the desired formula.
□
Lemma 1 is sharp in that the hypothesis cannot be replaced with the weaker hypothesis For example, , but
Lemma 2.
A binomial coefficient is odd if and only if for some
Proof.
Kummer’s theorem kummer (see (moll, , p. 78) or pomerance ) for the prime states that equals the number of carries when adding and in base arithmetic. Hence is the number of ones in the binary expansion of , and so if and only if for some . As by (13), we are done.
□
We can now prove the converse of Babbage’s non-primality test for even numbers.
Theorem 1.5.
For not a power of Lemma 2 implies that is even, so is congruent modulo to either [math] or . For a power of , say , the equalities in (16) and the symmetry yield
[TABLE]
and Lemma 1 implies that and that when ; thus, by addition . Hence for all we have . Now as divides when is even, (11) holds a fortiori. This completes the proof.
□
Index
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1(1) C. Babbage, Demonstration of a theorem relating to prime numbers, Edinburgh Phil. J. 1 , 46–49 (1819); available at http://books.google.com/books?id=Kr A-AAAAYAAJ&pg=PA 46
- 2(2) C. Babbage, Passages from the Life of a Philosopher (Longman, Green, Longman, Roberts, & Green, London, 1864); available at http://djm.cc/library/Passages_Life_of_a_Philosopher_Babbage_edited.pdf
- 3(3) C. G. Bachet, Problèmes plaisants et délectables, qui se font par les nombres , 2nd edn. (Rigaud, Lyon, 1624); available at http://bsb 3.bsb.lrz.de/~db/1008/bsb 10081407/images/bsb 10081407_00036
- 4(4) W. A. Beyer, review of dubbey , Am. Math. Mon. 86 , 66–67 (1979)
- 5(5) B. D. Blackwood, Charles Babbage. In: D. R. Franceschetti (ed) Biographical Encyclopedia of Mathematicians . (Cavendish, New York, 1998), pp. 33–36; available at http://www.blackwood.org/Babbage.htm
- 6(6) É. Barbin, J. Borowczyk, J.-L. Chabert, A. Djebbar, M. Guillemot, J.-C. Martzloff, and A. Michel-Pajus, A History of Algorithms: From the Pebble to the Microchip . J.-L. Chabert (ed). Trans. by C. Weeks (Springer, Berlin and Heidelberg, 2012)
- 7(7) J. M. Dubbey, The Mathematical Work of Charles Babbage (Cambridge Univ. Press, Cambridge, 1978)
- 8(8) N. J. Fine, Binomial coefficients modulo a prime, Am. Math. Mon. 54 , 589–592 (1947)
