Wolstenholme and Vandiver primes
Abstract.
A prime is a Wolstenholme prime if mod , or, equivalently, if divides the numerator of the Bernoulli number ; a Vandiver prime is one that divides the Euler number . Only two Wolstenholme primes and eight Vandiver primes are known. We increase the search range in the first case by a factor of ten, and show that no additional Wolstenholme primes exist up to , and in the second case by a factor of twenty, proving that no additional Vandiver primes occur up to this same bound. To facilitate this, we develop a number of new congruences for Bernoulli and Euler numbers mod that are favorable for computation, and we implement some highly parallel searches using GPUs.
Key words and phrases:
Wolstenholme primes, Vandiver primes, Bernoulli numbers, Euler numbers, irregular primes, -irregular primes.2000 Mathematics Subject Classification:
Primary: 11B68, 11Y40; Secondary: 11A41, 11B651. Introduction
In 1862, Wolstenholme [Wolstenholme] established that the following three congruences hold for every prime :
These results are closely related: if the stronger congruence obtained by replacing the modulus by holds in one of the expressions above for a particular prime , then a similar strengthening for that same prime holds in all of them. See [Gardiner] for a proof, [AebiCairns] for remarks on higher-order congruences, and [MestrovicSurvey] for a survey on other generalizations and extensions of Wolstenholme’s theorem. A Wolstenholme prime (first defined by McIntosh [McIntosh]) is an odd prime for which any of the following congruences holds:
(1.1) |
Many conditions equivalent to these are also well known. For example, in the last congruence, the constant may be replaced by any integer not divisible by . It is also straightforward to rewrite that generalized congruence as
which some authors employ.
Recall the Bernoulli numbers may be defined by their exponential generating function,
These are rational numbers, and for . An important connection between certain binomial coefficients and Bernoulli numbers was established by Glaisher in 1900 (combining [Glaisher1, §39] and [Glaisher2, §8]), who proved that
(1.2) |
for any prime and any positive integer . Thus, is a Wolstenholme prime if and only if divides the numerator of the Bernoulli number . This condition provides the first observation toward a more computationally attractive test for Wolstenholme primes, since it requires computation of a residue mod , rather than a higher power of .
Glaisher’s observation implies that a Wolstenholme prime is a particular type of irregular prime. Recall that a prime is said to be regular if does not divide the class number of the cyclotomic field , where . Equivalently, is regular if does not divide the numerator of any of the Bernoulli numbers with . Regular primes were first defined in the context of work on Fermat’s Last Theorem, as Kummer proved in 1847 that no nontrivial solutions with exponent exist in this famous problem if is a regular prime. The smallest irregular prime is , and while it is known that there exist infinitely many irregular primes (see for instance \citelist[Carlitz54][LPMP15]), it remains unknown if the number of regular primes is infinite. We refer the reader to [Edwards, Washington] for more information on regular primes and their connections to various topics in number theory.
The Euler numbers may also be defined by their exponential generating function,111Some authors instead use the series for the hyperbolic secant, , to define the Euler numbers; this alters the sign of the terms with index congruent to mod . Results cited from the literature that employ that formulation are suitably translated here to comport with the definition we employ.
Like the Bernoulli numbers, the Euler numbers with odd index are (including this time), but unlike the , the Euler numbers are all integers. A prime is said to be -regular if does not divide any of the Euler numbers with . The smallest -irregular prime is , as , and while it is known that there exist infinitely many -irregular primes \citelist[Carlitz54][LPMP15], it is also not known if the number of -regular primes is infinite. -irregular primes first arose in the study of Fermat’s Last Theorem as well, and they are pertinent in other problems in number theory too, including the topic of class numbers of cyclotomic fields. For example, Gut [Gut] proved that does not divide the class number of the cyclotomic field if and only if and mod for .
The extremal case mod has witnessed particular interest. In 1940, Vandiver [Vandiver40] showed that any solution with exponent in the first case of Fermat’s Last Theorem (so a nontrivial solution in positive integers to where ) necessarily has . More recently, Z.-H. Sun [ZHSun08] and Z.-W. Sun [ZWSun11] established a number of congruences regarding Bernoulli and Euler numbers, in many of which the residues of and mod play an important role, and several of these congruences become stronger in the case of a Wolstenholme or Vandiver prime.
If is irregular, and mod for an even integer , then is known as an irregular pair. A Wolstenholme prime is thus the extremal case where forms an irregular pair. Only two Wolstenholme primes are known, and both were discovered during broader searches for irregular primes. The smallest Wolstenholme prime is . This seems to have been first discovered by Selfridge and Pollack, who spoke on their work searching for irregular primes up to at a meeting of the American Mathematical Society in 1964 [SelfridgePollack]. While details from their search are not readily available, in 1975 Johnson [Johnson75] reported on an extension of the work of Selfridge and Pollack, verifying their work, and noted in particular that was the only prime less than where forms an irregular pair.
The second Wolstenholme prime is , and was discovered in 1993 by Buhler et al. [BCEM93] during a search for irregular primes . In 1995 McIntosh [McIntosh] reported finding no additional examples with , after more extensive searches that targeted Wolstenholme primes in particular, and then (with Roettger) extended this search in 2007 [McIntoshRoettger] to . More recently, McIntosh continued this search to cover [McIntoshFQ] and found no additional examples. Broader searches for irregular primes have continued as well, culminating most recently in the work of Hart, Harvey, and Ong [HHO] of 2017, who determined all irregular primes , along with their index of irregularity, that is, the number of irregular pairs attached to each such prime. They found for instance that the maximum index of irregularity over this range is , attained by the single prime .
We likewise say is an -irregular pair if mod , so that a Vandiver prime has the property that forms an -irregular pair. It appears that the last census of -irregular primes and indices of -irregularity was performed in 1978 by Ernvall and Metsänkylä \citelist[Ernvall79][EM78], who checked primes , motivated by questions regarding Iwasawa invariants of the cyclotomic field . They found for example that the maximum index of -irregularity over this range was , attained by alone.
A number of Vandiver primes were known prior to this work. The first two, and , were first noted by Ernvall and Metsänkylä [EM78] (and later rediscovered by Z.-W. Sun [ZWSun11]). Three more Vandiver primes, , , and , were found by Cosgrave and Dilcher in 2013 [CosgraveDilcher] (who called these integers -primes), using a congruence from [ELehmer] to search up to . They showed that these primes arise in a natural way in a problem regarding modular sums of certain reciprocals, proving that
precisely when or is divisible by a Vandiver prime. Cosgrave and Dilcher also reported that in 2012 McIntosh found three additional such primes in a search to : , , and . More recently, McIntosh extended this to [McIntoshFQ], finding no additional examples. We also report that in 2014 Meštrović [Mestrovic14] employed a congruence of Z.-H. Sun from [ZHSun08] involving the computation of certain harmonic numbers modulo to compute the Vandiver primes .
In the absence of any special structure, one might expect the values of or to be uniformly distributed modulo .222We remark that some structure does appear in a similar problem. The Ankeny–Artin–Chowla conjecture asserts that for every prime mod . While this problem is open in general (and has been verified computationally for [VTW]), this conjecture is known to hold for primes of the form or [Agoh]. Numerical evidence weighs in support of this: see Figures 1 and 2 later in this paper. If this is true, then as McIntosh [McIntosh] has pointed out, one would expect that infinitely many of each of these kinds of primes exist, since the sum of the reciprocals of the primes diverges. In this case, the expected number of either type of prime up to would grow approximately as . One might define a super-Wolstenholme prime by requiring a congruence in (1.1) to hold modulo a higher power of , and similarly for a super-Vandiver prime. Similar heuristic considerations lead one to expect that only a finite number of such primes exist. In [McIntosh] McIntosh conjectured that no super-Wolstenholme primes exist; this seems likely to be true as well for super-Vandiver primes.
In this article, we describe searches for Wolstenholme and Vandiver primes that reach eight times farther than any prior search in the former case, and twelve times farther in the latter. We establish that no additional examples of either type occur across the ranges we check.
Theorem 1.1.
The Wolstenholme primes less than are and ; the Vandiver primes less than are , , , , , , , and .
There are two principal components to our method which allowed us to extend these searches by substantial factors. First, we obtain new congruences for Bernoulli and Euler numbers modulo a prime , which allow us to compute residues of these numbers with greater efficiency. See (2.8), (2.9), (2.10), (2.11), and (2.12) for successively more efficient (and more complicated) congruences for the Bernoulli numbers, and similarly see (4.2), (4.3), (4.4), (4.5), (4.6), and (4.9) for our congruences for the Euler numbers. For the Bernoulli numbers, our congruences extend and improve on some results of Tanner and Wagstaff from 1987 [TannerWagstaff]. Second, we employ graphics processing units (GPUs) to implement a heavily parallelized approach.
We also answer in the affirmative a question raised by Tanner and Wagstaff regarding the existence of congruences for Bernoulli numbers mod involving fewer than terms, for arbitrarily small —see Theorem 6.1. This result applies equally well to the computation of Euler numbers mod .
This article is organized in the following way. Section 2 derives a number of new congruences for Bernoulli numbers which are advantageous for computing, particularly for large primes. Section 3 then describes our search for Wolstenholme primes using these congruences and summarizes the results of our searches in this problem up to . Section 4 establishes some new congruences amenable for our computations on Euler numbers, and Section 5 describes our search for Vandiver primes and summarizes our results up to this same bound. Section 6 establishes that congruences with fewer than terms exist for computing residues of Bernoulli or Euler numbers, for arbitrary , and Section 7 adds some observations regarding derivations of favorable congruences.
2. Congruences for Bernoulli numbers
The Bernoulli numbers are known to satisfy a number of congruences involving sums of powers of consecutive integers, beginning with Voronoi’s well-known congruence of 1889 (see [UspenskyHeaslet, Chap. IX]). Some of these congruences have been particularly instrumental in calculations involving Bernoulli numbers. We review some of the more important relations. For real numbers in , an integer , and a prime , let
(2.1) |
and, for positive integers , , and a positive integer , let
With this notation, in 1930 Stafford and Vandiver [StaffordVandiver, eq. (9)]] (see also [TannerWagstaff, Thm. 1]) established that
(2.2) |
whenever and . Note that this allows computing the residue of mod using a sum with approximately terms. Also, in 1937, Vandiver [Vandiver37, eq. (18)] proved that
(2.3) |
when and . For convenience, we define the cost of a congruence such as (2.2) or (2.3), where in general the right side consists of a linear combination of sums , …, , as
as this is the approximate number of terms in the sums comprising the right side of the congruence. The cost of Vandiver’s congruence (2.3) is thus , and the cost of (2.2) is . However, it transpires that (2.3) is more important for our application.
In 1987, Tanner and Wagstaff [TannerWagstaff] developed a number of new congruences for Bernoulli numbers. They proved for example that
(2.4) |
whenever is prime, , , , and . This rule has cost , so asymptotically , and we note that the case recovers (2.3). Tanner and Wagstaff also noted three simple transformations that preserve the value of mod , which we summarize here, in a slightly generalized form.
Proposition 2.1 (Tanner and Wagstaff [TannerWagstaff]).
The following three properties hold for , defined in (2.1).
-
(a)
Separation: If and is not an integer, then
-
(b)
Reflection: .
-
(c)
Subdivision: If is a positive integer and , then
We include the short proof here for the convenience of the reader.
Proof.
The first two properties are immediate from the definition of . For the third, since , every integer can be expressed in a unique way as for some integer . Therefore,
One may employ the transformations of Proposition 2.1 to create new congruences for Bernoulli numbers from existing ones. While each transformation preserves the cost of the sums involved, one might hope that subdivision and reflection might create new expressions with some overlapping sums, so that separation may be employed to collect like terms, and thus produce congruences with reduced cost, at the price of some more complicated coefficients. For example, as noted in [TannerWagstaff], if one applies subdivision with to the second term of (2.3), and then reflection to the resulting term having , then one obtains
(2.5) |
provided and . This new expression has two sums, each now possessing modestly more complicated coefficients, but the cost of this congruence has dropped to . Tanner and Wagstaff also derived a more complicated congruence for Bernoulli numbers with more sums and lower cost. By starting with (2.4) in the case , and employing five prescribed subdivision steps in sequence, using reflection and separation as appropriate for simplification, they found a congruence for mod having seven sums with cost . They also reported that beginning with the congruence (2.5) and applying two particular subdivision operations, together with appropriate simplifications, produces an expression with cost . While the resulting congruence is not reported, we find that it has eight sums. Finally, it is mentioned in the same article that the authors could construct a more complicated congruence with approximate cost , but its construction is not specified.
We use Proposition 2.1 to search for congruences for Bernoulli numbers mod that are particularly favorable for computations. Certainly, it is advantageous to employ a congruence with small cost, but one must also be concerned with the number of sums appearing in the expressions, as well as the size and complexity of their coefficients, as each of these contributes to overhead costs in computations. It may also be helpful for each sum in a congruence to have a comparable number of elements, for balancing loads in parallel environments. In addition, for larger primes we may be able to tolerate greater overhead costs, so we therefore seek a family of congruences for Bernoulli numbers mod : for a range of small positive integers , we would like an expression for having exactly sums with cost , with as large as possible.
The case was the subject of a search by Wagstaff [Wagstaff], who found nothing better than the value exhibited by (2.2), as well as by the well-known relation (see, e.g., [UspenskyHeaslet, ex. IX.6])
(2.6) |
valid for primes when . This latter relation follows from Voronoi’s congruence, and in fact is the case in (2.4). We searched for improved values for some larger by using Proposition 2.1, with a number of starting relations.
We employed two strategies in searching for useful congruences: exhaustive searches, and heuristic searches. We describe each of these below, along with its principal results.
2.1. Exhaustive searches
In an exhaustive search, we supply a starting congruence such as (2.2), along with a list of positive integers , and we construct all possible congruences that can be formed with a sequence of at most subdivision operations starting from our initial congruence, where the th subdivision employs a value of satisfying . We make a number of runs with this method using different initial lists , some with a small value of like and larger values for the such as or , and some with a larger value of like , where we limit the to smaller values such as or . After each subdivision, we use the reflection and separation properties to simplify our expressions as much as possible. Over several runs with different parameters we maintain a list that stores for each the smallest cost of a congruence having sums that was constructed from the given starting relation, along with information on how to construct it. For starting relations, we employed each of the congruences (2.2), (2.3), (2.4) with , (2.6), as well as the well-known relation
(2.7) |
which is valid for and and has cost . This last expression also follows from Voronoi’s congruence [UspenskyHeaslet, ex. IX.6]. In addition, in order to search more effectively at larger values of , we would start this procedure at a favorable congruence observed at a smaller value of . For example, many improved values for were found by starting a search at the best known congruence at .
Table 1 summarizes the results of our searches using this strategy, displaying the minimal cost discovered among congruences having exactly sums, for a range of values of . In each case, the best example we found was constructed using Vandiver’s congruence (2.3) as its starting point. We therefore assume and in all congruences displayed in the remainder of this section. We provide details only on the congruences from Table 1 that were employed in our searches for Wolstenholme primes, described in Section 3.
For , the best example we find is in fact (2.5), where .
For , we find a congruence with cost , so this requires two fewer sums than the congruence with the same cost reported in [TannerWagstaff]. To obtain this, starting with (2.5) one subdivides the term with , simplifies appropriately, then subdivides using , then the term with , and finally subdivides the resulting sum with . Writing for economy, this produces the six-term congruence
(2.8) |
Here, the cost of each sum is respectively , , , , , and , so this example has .
We remark that intermediate expressions generated when creating (2.8) in this way produce two more of the entries in Table 1. Applying just the first two subdivisions described above to (2.5) produces our congruence with sums and cost ; applying the third subdivision to this manufactures our example at with cost .
We also find a particularly well-balanced example with small cost at . Again starting with Vandiver’s congruence (2.3), we first subdivide with , then subdivide the resulting sums and using , and finally subdivide with . This produces the nine-term congruence
(2.9) |
where again we write for . Each sum here has the same cost, , so this expression achieves . Figure 4 in Section 7 depicts the transformation of (2.3) into (2.9).
We provide details on two additional congruences from Table 1, which are employed in the searches described in the next section. For an expression with sums and cost , starting from (2.9) we subdivide both the and the sums using , then subdivide with , and finally subdivide the resulting sums and with . This yields
(2.10) |
Here, while the costs of the individual sums vary considerably, from to , the cost of the entire rule is just , so exactly half that of (2.2).
We also record the derivation of the -term congruence referenced in Table 1. Starting from (2.10), subdivide with , and then subdivide each of , , , and in turn using . This yields
(2.11) |
which has cost .
Finally, we describe an additional congruence for Bernoulli numbers with sums that is employed in some of our searches: from (2.11), subdivide using , and then apply this transformation with to each of , , and in turn. This produces
(2.12) |
with cost .
2.2. Heuristic searches
Our second strategy looks for congruences with small cost, without regard to the number of sums or the complexity of the coefficients in the resulting expression. This search is designed to investigate in an empirical way the question raised by Tanner and Wagstaff [TannerWagstaff] of whether there exist congruences with cost less than for arbitrarily small . We provide a general construction that answers this question in the affirmative in Section 6.
In our heuristic searches, we begin with an initial congruence and positive integers and . We then construct all possible congruences using subdivision operations, each using a value . We select a congruence of minimal cost from this set, and recursively invoke the algorithm using this as our starting congruence. This continues for a number of rounds. We keep small, often starting with , then switching to after a particular number of steps. We typically select or . This method thus makes locally optimal choices to construct congruences with very low cost. Figure 3 in Section 6 depicts the progress of this method with and , beginning with (2.5).
Beginning with Vandiver’s congruence (2.3), we use this method to construct a congruence for Bernoulli numbers mod having cost
The expression we constructed contains sums, but there is no reason to believe this is optimal.
3. Searching for Wolstenholme primes
Using Glaisher’s congruence (1.2), we have that is a Wolstenholme prime if and only if . We employ the congruences from the prior section to compute the residue of mod for primes , using . In this case, mod , so for example (2.5) becomes
that is,
(3.1) |
Here and throughout this section, all congruences are understood to be taken mod . In the same way, the congruences (2.2), (2.8), (2.9), (2.10), (2.11), and (2.12) produce respectively (writing for throughout for economy of space)
(3.2) | |||
(3.3) | |||
(3.4) | |||
(3.5) | |||
(3.6) |
and
(3.7) |
It remains to describe how to calculate these sums efficiently. For this, we first note that
We employ the method described in [McIntoshRoettger] (aided there by P. Montgomery) to compute the latter value. Corresponding to a sum with fixed, we define the polynomial
and by expansion it follows that mod . We may therefore compute the value of mod with the following simple procedure:
(3.8) |
We use Nvidia Tesla V100 GPUs to compute these sums. Each GPU consists of streaming multiprocessors (SMs), each of which can execute up to threads concurrently, although in our computation this needs to reduce to threads per SM, owing to our need to work with -bit arithmetic. Each GPU works in concert with an attached CPU. The CPU is tasked with a range of integers to check. We describe our method first for primes , and then some improvements implemented for larger primes.
3.1. Method for primes
Over this range, computations for one prime are completed before those for another prime are begun, and the GPU is employed to compute each sum in the current congruence in a highly parallel way. Given , , and , the GPU divides the integers in into arithmetic progressions of approximately equal size, one progression for each thread. Each thread uses the strategy of (LABEL:eqnComputeS), replacing the interval with an appropriate arithmetic progression , to compute the constant coefficient and the linear coefficient mod for the polynomial
(3.9) |
The GPU then reduces these pairs of values down to pairs with ten further rounds of parallel calculations. Each round halves the number of current pairs by combining two pairs and via
(3.10) |
computing the coefficients mod . This process ends after ten rounds because only the threads operating in the same block, that is, executing within the same SM, can share memory easily. After this, the CPU handles the final reduction, using (3.10) iteratively to combine the remaining pairs into a single pair, which represents the values of and for the entire sum mod . Once all the sums in the congruence have been computed, the CPU then combines their values, incorporates the appropriate coefficients, and computes the appropriate inverse mod , to determine the residue of .
It remains to select the congruence employed at each stage of the computation. While more complicated congruences like (3.4) and (3.5) have smaller cost than simpler congruences like (3.1) and (3.2), the congruences with a larger number of sums require greater computational overhead in invoking the GPU multiple times and combining the results of these calls, so the more complex methods are only economical for larger values of . For example, we found that the nine-term congruence (3.4) did not offer any savings over the six-term congruence (3.3) for primes near , even though the nominal cost of the former congruence is slightly better.
Consequently, we employed different congruences over our computation. We employed the simple congruence (3.2), with cost , for primes . We then switched to the six-term congruence (3.3), with cost , for . After this, we used the nine-term congruence (3.4), with cost , for , then the -term expression (3.5), with cost , up to , followed by the -term congruence (LABEL:eqnBB22), with cost up to , and finally the -term congruence (3.7) with cost for . This strategy was not optimal: certainly we would have saved time by employing the two-term congruence (3.1), which features cost , at an appropriate stage.
Employing GPUs in this way allowed for much faster calculations compared to prior searches. The congruence (3.2) was employed in prior searches for Wolstenholme primes [McIntosh, McIntoshRoettger, McIntoshFQ], and in [McIntoshRoettger] it was reported that determining whether mod using this congruence for a single prime near required about seconds of CPU time, using MIPS R12000 processors. Using the same congruence, our GPU implementation requires approximately milliseconds per prime near to compute mod on a CPU-GPU pair. The contrast remains stark when we compare our CPU-GPU implementation with a CPU-only implementation that employs the more modern Intel Xeon Cascade Lake processors: these require about seconds per prime in that range to compute mod . We remark also that the GPU method with the slightly more complicated congruence (3.1) computes mod for primes near in an average of just milliseconds per prime, so this two-term congruence is advantageous compared to (3.2), even for near .
We employed native arithmetic whenever possible. For , each multiplication operation mod produces an intermediate result that fits in a -bit long word, so each such operation required one multiplication instruction and one modular reduction operation. Larger primes required more care. In the general case, in order to multiply and mod , with , we write and , so that
(3.11) |
This allows us to compute this product without arithmetic overflow. We note that for a given prime we compute mod just once, using one modular reduction and one addition, so that the amortized cost of computing the expression (3.11) mod is four multiplications, four modular reductions, two bit shifts, and three additions, plus two bitwise “and” operations and two additional bit shifts used to create the operands from and .
We took advantage of certain optimizations that are available over particular ranges. For example, when computing a sum with when , then for the quantity mod can be calculated natively. For we typically needed to use (3.11) in its full generality.
For a prime near , this strategy computes the value of mod using the -term congruence (3.7) in approximately milliseconds.
3.2. Method for primes
Three improvements to our strategy implemented for primes larger than produced significantly faster run times.
-
(1)
Each thread on the GPU needs to compute the and values for (3.9), and so must compute the values of mod across the values of an arithmetic progression. Rather than compute each value independently, however, we can use the value of mod to produce the value of by adding their difference. This requires tracking , but that value can be maintained with a similar strategy, and likewise for linear terms. This significantly reduces the number of modular multiplications performed on the GPU, which were fairly expensive operations, implemented using several atomic steps as in (3.11). This cut our run time by for near .
-
(2)
When computing mod on the GPU, we had used an integer remainder operator. However, instead we can use a floating-point division to determine the approximate quotient, truncate the result, and then use one multiplication and one subtraction to compute the integer remainder. This is safe provided , and we remain well short of this bound. This reduced our run times by an additional beyond the improvement from the first item.
-
(3)
Rather than treat the primes one by one, splitting the work on each prime across the thousands of threads on the GPU, we can assign each thread on the GPU its own prime, and process primes at once. This reduces the overhead per prime and simplifies our code further (since we now have arithmetic progressions with difference ), but comes with the disadvantage that threads handling larger primes will take longer than those on smaller primes, and we need to wait until all threads complete before assigning a new task to the GPU. On balance, this is a win, gaining an additional in our amortized run time per prime.
Overall, our run times dropped by using these improvements: the amortized cost of testing one prime near with this strategy using the -term congruence (3.7) was about milliseconds. We used this strategy to complete our check to . At the end of our run, the time required per prime was about msec. We can also report that a prime near can be tested with an amortized cost of approximately msec using these improvements.
3.3. Results
Our searches found that no Wolstenholme primes with exist. We record here some “near misses”: let denote the unique representative of mod lying in . Table 2 records the primes with where ; a Wolstenholme prime would of course have . All computations were performed on Gadi, a high-performance computer managed by NCI Australia. Beyond , the package primesieve [Walisch] was employed to enumerate primes over intervals.
|
|
We discern no particular bias among the values of mod . Figure 1 displays a histogram with bins of equal size for the values of over the primes with ; a perfectly uniform distribution would display as a horizontal line at .

4. Congruences for Euler numbers
In 1902, Glaisher [Glaisher3, §34] established a formula for the residue of Euler numbers modulo a prime . Using our notation, this is
(4.1) |
when , is a positive even integer, and . Special cases of this congruence also appear in [ELehmer, p. 359] and [ZHSun08, Cor. 3.7]. This congruence has cost , and was employed in prior searches for Vandiver primes [McIntoshFQ]. We apply the exhaustive search strategy from Section 2.1, using similar parameters, to determine some congruences equivalent to (4.1) with smaller cost.
We describe the derivation of four favorable congruences having , , , and terms respectively, which stem from (4.1), and which were employed in our calculations. We assume and throughout. For our congruence with , apply subdivision with to in (4.1), and then the same transformation to the resulting term . After simplifying using reflection and separation as required, we obtain
(4.2) |
where we write for for brevity. This congruence has cost .
For , we apply two more subdivision transformations on (4.2) with , on and then on , to produce our congruence with cost :
(4.3) |
Next, for , we subdivide the term from (4.3) with and using to produce
(4.4) |
which has cost , so less than half that of (4.1). For , we subdivide the and terms from (4.4) with , and , , and with to yield
(4.5) |
for a cost of . Last, for our relation with , we subdivide the terms , , and in (4.5) using , , and respectively, and then subdivide and in the resulting expression with to obtain
(4.6) |
which has cost .
We also find that we can derive some better congruences by using another starting relation. In [McIntoshFQ], McIntosh proved that
(4.7) |
provided and , where
It is straightforward to verify that the separation and reflection properties of Proposition 2.1 hold for as well as , but the alternating sign in requires an alteration to the subdivision property: if is a positive integer and , then
We apply a subdivision operation with to the expression in (4.7), producing (writing for )
(4.8) |
After this we may apply the transformations of Proposition 2.1 in the usual way. Using this strategy, we obtain congruences with costs lower than those we could construct using (4.1) as our base. We record just one such congruence here, as it is employed in our searches. Starting with (4.8) and applying the sixteen subdivision steps
in sequence, and simplifying appropriately using reflection and separation after each step, we obtain the following congruence for Euler numbers with cost , which holds for and :
(4.9) |
Finally, we remark that using the heuristic optimization method of Section 2.2, with only modest effort we can construct more complicated congruences with cost less than . We produced one such congruence having terms with a greedy search beginning at (4.8) and using and , iterating over rounds. A similar search beginning with (4.1) produced a congruence with terms and cost near .
5. Searching for Vandiver primes
In order to search for Vandiver primes, we require the case in the congruences of the prior section. Since mod , we use in (4.2), (4.3), (4.4), (4.5), (4.6), and (4.9) to obtain the following congruences. Here, we omit the subscript on the terms for brevity, and naturally each of these congruences is understood to be taken modulo . We assume throughout.
(5.1) | |||
(5.2) | |||
(5.3) | |||
(5.4) | |||
(5.5) | |||
(5.6) |
We may compute each sum in the same manner as our Wolstenholme searches, employing the same polynomial method by computing the linear and constant coefficients of the polynomial , similar to the procedure of (LABEL:eqnComputeS). These sums were again computed using GPUs, using a strategy similar to that of Section 3.1 for primes , and utilizing the improvements of Section 3.2 for larger primes. The first improvement, tracking differences across an arithmetic progression when computing powers, yielded a more modest gain in this case, since we require squares here instead of cubes, but our overall gain over all three improvements was quite similar to the Wolstenholme case, at . Near , the amortized cost of computing mod for a single prime using (LABEL:eqnEE33) dropped from approximately milliseconds before the improvements to about msec with them. Near , the average time per prime measured about msec.
We employed the congruence (5.1) for the search range , followed by (5.2) for , then (5.3) for , then (5.4) for , followed by (5.5) for , and finally (LABEL:eqnEE33) for .
Our searches found no new Vandiver primes larger than . Table 3 records the primes with where ; a Vandiver prime has . Computations were again completed at NCI Australia, and primesieve [Walisch] employed for enumerating primes above .
|
|
As with the Bernoulli numbers, we observe no particular bias among the values of mod . Figure 2 displays a histogram with equal-sized bins for the values of over the primes with .

6. Congruences with arbitrarily small cost
In [TannerWagstaff], Tanner and Wagstaff raised the question of whether there exist congruences for computing Bernoulli numbers involving linear combinations of the sums having cost less than , for any . One may ask the same question regarding the computation of residues for Euler numbers. We answer both questions in the affirmative here, by showing that any such sum has an equivalent formulation with arbitrarily small cost.
Theorem 6.1.
Let be rational numbers in , let be an odd prime number that does not divide the denominators of and , and let be an integer. Given , there exist disjoint intervals , …, in and integers , …, , with the , , and independent of , so that
where the cost of the right side is less than .
Proof.
Let be a common denominator for and with the property that with . Set so that
by the separation property of Proposition 2.1. Partition into two subsets and of equal size. For each , use the subdivision property with to write
(6.1) |
For each , use the separation property to write
(6.2) |
For each pair , the right sides of (6.1) and (6.2) have one term in common, when and . These terms are disjoint, so the cost of our new expression is
The transformed sum involves intervals, each of size , and since we can iterate this process. Using the fact that is increasing on , a straightforward inductive argument shows that after iterations the cost of our expression is less than , and we may choose large enough so that this is . ∎
By applying this procedure to (2.2) and (4.1), it follows immediately that there exist congruences for Bernoulli numbers and Euler numbers mod with arbitrarily small cost, assuming .
We remark also that the convergence rate obtained by this method is rather slow: since there are terms in the sum after iterations, the cost is . Perhaps an alternative method could supply an improved convergence rate: empirical evidence from our computations in Section 2.2 and the end of Section 4 suggests that is possible, and we conjecture this to be the case. Figure 3, for example, shows the progress made by iterating this greedy method, beginning with (2.5), and using parameters and . Here, we plot the point if a congruence produced had terms and cost . The best-fit curve of the form is also displayed: here and .

We provide a few basic bounds related to derivations of congruences in the next section.
7. The transformation graph
While not directly applicable to the search for Wolstenholme and Vandiver primes, this section is devoted to developing ideas of the Tanner and Wagstaff machinery that generates new congruence relations for Bernoulli numbers and Euler numbers. These congruence relations are crucial to the aforementioned search and any insight into their derivation could be useful in future work.
We define a derived congruence relation as one that is generated from another congruence relation of the type (2.4) using the transformations of Proposition 2.1—separation, reflection, and subdivision. To conveniently represent these transformations, we will denote separation by , where denotes the fraction by which we split the interval into two, i.e., if , then a transformation applied on will result in
Similarly, reflection is denoted by and subdivision into terms is denoted by . We will also use to denote the identity transformation which will be used only to indicate termination of a chain of transformations.
Starting from (2.4), we can draw a tree of transformations corresponding to each of the terms, where identity/terminal (), separation (), reflection (), and subdivision () result in one, two, one, and branches, respectively. The union of the trees will be referred to as a transformation graph. This graph can be traversed in a depth-first-search manner, sequentially from the first tree to the th tree, to give a unique string identifying the series of transformations. For example, Figure 4 depicts the transformations needed to derive (2.9) from (2.4) with in the form of a graph with two trees corresponding to the two terms in the original congruence relation. The string of transformations corresponding to this is
The final congruence (2.9) can be obtained by merging the leaf nodes, after multiplying them by the appropriate coefficients.

Using the idea of a transformation graph, we can now prove a basic bound relating to the question posed by Tanner and Wagstaff in [TannerWagstaff] on the existence of congruences with cost less than . Assume that the desired cost of a derived congruence is less than or equal to and the least number of terms possible for such a congruence is . Here, a term is an expression of the form in the derived congruence, being the appropriate coefficient generated during the transformations. Let the total number of leaf nodes (which are then merged into terms) in the transformation graph be . The derived congruence has the form
Since the desired cost is at most , we have and therefore,
(7.1) |
for each and
(7.2) |
for some .
Trivially, . The cost of each term in (2.4) is . If , we need to apply a string of transformations to obtain terms with reduced cost. Among the various transformations, only separation and subdivision yield terms with lower cost than the original. To reduce the cost of each term while generating the least number of extra terms, it is clear that one cannot do better than applying a single subdivision operation, , such that (from (7.1))
where is an integer depending on . The value might be interpreted as the number of leaf nodes in the th tree corresponding to the th term of (2.4). Note that other sequences of transformations might exist that generate the same number of terms with the required cost but for our purposes, this assumption is sufficient.
Therefore, we obtain . In other words, is a lower bound on the number of branches (and hence, leaf nodes) that need to be generated in each tree in order to satisfy (7.1). Therefore,
(7.3) |
From (7.2), we know that for some , we have , or
(7.4) |
where is the maximum number of leaf nodes in any tree in the graph. In fact, we can refine (7.3) slightly:
(7.5) |
Proposition 7.1.
.
The fraction is the ratio of distinct leaf nodes to all leaf nodes, so Proposition 7.1 implies that, depending on , , and , a certain proportion of leaf nodes must occur more than once. In particular, for fixed and , as the ratio approaches .
Acknowledgements
We thank Karl Dilcher, Lars Hesselholt, and Richard McIntosh for helpful correspondence. We also thank NCI Australia and UNSW Canberra for computational resources. This research was undertaken with the assistance of resources and services from the National Computational Infrastructure (NCI), which is supported by the Australian Government.