Wagstaff Prime Calculator
Number Theory
- The Wagstaff form is W(p) = (2^p + 1) / 3; here W(13) = (2^13 + 1) / 3 = 2,731. The division by 3 is exact for every odd exponent.
- Deterministic Miller-Rabin testing (12 bases, cross-checked with a Baillie-PSW test) finds no factor, and W(13) is prime.
- W(13) is a Wagstaff prime.
- Confirmed Wagstaff prime exponents include 3, 5, 7, 11, 13, 17, 19, 23, 31, 43, 61, 79, 101, 127, 167, 191, 199 and 313 - the list thins out very quickly.
A Wagstaff prime is a prime of the form W(p) = (2^p + 1) / 3, where p is itself prime. Named for Samuel Wagstaff, who studied them in the hunt for new Mersenne-like primes, they thin out ferociously: the exponents below 200 are just 3, 5, 7, 11, 13, 17, 19, 23, 31, 43, 61, 79, 101, 127, 167, 191 and 199 - seventeen in total - and each one certifies a prime vastly larger than the exponent suggests. W(13) is a modest 2,731; W(199) has 60 digits.
This calculator tests an exponent by building W(p) in exact big-integer arithmetic and proving primality two independent ways - a deterministic Miller-Rabin test and a Baillie-PSW test, which must agree. For composite cases like W(29) = 178,956,971 it exhibits a factor - 59 - so the verdict can be checked by division. List mode shows the proven exponents up to your bound.
Wagstaff primes matter beyond sport: numbers of this form admit fast primality proofs, making them useful test-beds for the algorithms that certify the giant primes used in computational number theory - and every new one found is a small event in that world.
Worked examples
Exponent 13 - W(13) = 2,731 is prime
(Test an exponent · 13 · 200)
| Wagstaff primality result | W(13) is prime - a Wagstaff prime |
| Wagstaff number W(p) | 2,731 |
| Form | W(p) = (2^p + 1) / 3 |
| Exponent p | 13 |
Exponent 29 - W(29) is composite
(Test an exponent · 29 · 200)
| Wagstaff primality result | W(29) is composite |
| Wagstaff number W(p) | 178,956,971 |
| Form | W(p) = (2^p + 1) / 3 |
| Exponent p | 29 |
List Wagstaff prime exponents up to 200
(List exponents up to a bound · 13 · 200)
| Wagstaff primality result | 17 Wagstaff prime exponents up to 200 |
| Largest exponent | 199 |
| Count | 17 |
| Form | W(p) = (2^p + 1) / 3 |
Why the form works
For odd p, 2^p + 1 is divisible by 3 - because 2 is congruent to -1 modulo 3, so 2^p + 1 is congruent to -1 + 1 = 0 - which makes W(p) an integer. The exponent must be prime for a cleaner reason: if p factors as ab, then 2^a + 1 divides 2^p + 1 algebraically, and W(p) inherits a factor. Composite exponent, composite number, no exceptions - which is why the calculator rejects non-prime exponents before doing any heavy work.
The family sits between two famous neighbours: Mersenne numbers 2^p - 1 below, Fermat-like numbers above. Wagstaff's form, with its division by 3, produces numbers about a third the size of the corresponding Mersenne candidate, and its primality can be attacked with specialised tests in the same spirit.
Testing W(13) and W(29)
W(13) = (8,192 + 1) / 3 = 2,731. Miller-Rabin finds no witness against it across twelve bases; Baillie-PSW - a strong Miller-Rabin test plus a strong Lucas test - agrees; 2,731 is prime, and 13 takes its place in the exponent list. Two independent methods agreeing is the standard of evidence this page applies to every test.
W(29) = (536,870,912 + 1) / 3 = 178,956,971 fails immediately by comparison: 59 divides it (59 x 3,033,169 = 178,956,971), so 29 is not a Wagstaff exponent despite being prime. Most prime exponents fail this way - primality of p is necessary, never sufficient - which is why the exponent list has 17 entries below 200 rather than 46.
Two independent primality tests
Miller-Rabin writes n - 1 as d x 2^r and tests bases: a composite almost always betrays itself to some base. With the first twelve prime bases the test is deterministic far beyond the sizes used here. Baillie-PSW combines a base-2 strong test with a strong Lucas test using Selfridge's parameters; no composite is known to pass it at any size, and it is the test several major computer algebra systems trust by default.
Running both is deliberate redundancy of method, not of effort: they fail differently, so agreement is stronger evidence than either alone. For the record sizes this calculator handles - exponents to 200, numbers to 61 digits - both tests run in milliseconds, and the page reports which verdict each path supports through the factor it exhibits for composites.
The known exponents
Below 200 the exponents are 3, 5, 7, 11, 13, 17, 19, 23, 31, 43, 61, 79, 101, 127, 167, 191, 199. Beyond them the list continues 313, 347, 701, 1709, 2617, 3539 - each verified - and then thins into probable primes whose proofs await faster methods or bigger machines. The gaps widen brutally: between 199 and 313 there is room for a hundred primes, none of which yields a Wagstaff prime.
Heuristics predict infinitely many Wagstaff primes, with the count up to x growing like a constant times log log x - the same slow law as Mersenne primes. 'Infinitely many, logarithmically rare' is the standard conjecture for all these exponential prime families, proven for none of them.
Wagstaff and Mersenne
The comparison is instructive. Mersenne primes 2^p - 1 are hunted by GIMPS with the Lucas-Lehmer test, a proof method special to that form. Wagstaff numbers have their own specialised tests but a smaller search community, so their records advance in steps when someone points serious hardware at them. The largest known Wagstaff prime has hundreds of thousands of digits - far beyond this calculator's exact-arithmetic remit of exponents to 200.
What this page offers instead is certainty at human scale: every exponent to 200 tested by two methods, every composite convicted by a factor, every prime double-certified. For classroom and curiosity purposes, that is the interesting range anyway - it contains the entire history of the family up to the computer era.
Using the calculator
Test mode takes a prime exponent up to 200 and returns the primality of W(p), showing the number itself when it has at most 25 digits and its digit count beyond that. Non-prime exponents are declined with the algebraic reason. List mode filters the proven exponent list to your bound - 17 up to 200.
If you bring an exponent from another source claiming Wagstaff status beyond the proven list, treat it as a probable prime claim: possibly true, widely believed when the computation is careful, but a different epistemic category from the certified values this page trades in.
Small cases by hand
The family's foot of the hill is checkable with pencil arithmetic. W(3) = (8 + 1) / 3 = 3, prime. W(5) = (32 + 1) / 3 = 11, prime. W(7) = (128 + 1) / 3 = 43, prime. W(11) = (2,048 + 1) / 3 = 683, prime - 683 has no divisor up to its square root of about 26: not divisible by 3, 5, 7 (7 x 97 = 679), 11 (11 x 62 = 682), 13 (13 x 52 = 676), 17, 19 or 23. These four successes in a row are the last easy run the sequence ever has.
W(13) = 2,731 continues the pattern, and then the failures begin to outnumber the successes decisively. The calculator's list mode shows the survivors; the hand-checkable start of the sequence is the right way to convince yourself the definition has been implemented as advertised.
Probable primes and proof
Beyond the certified range, Wagstaff candidates are typically first reported as probable primes - numbers passing strong probable-prime tests without a formal proof - and promoted to proven primes later when a specialised proof (using the partial factorisation of W(p) minus or plus one) is completed. The distinction matters in the record lists: 'largest known Wagstaff prime' claims are sometimes probable, and the careful sources say which.
This page trades only in the certified range, exponents to 200, where two independent deterministic-grade tests settle every case. The boundary is chosen so that every verdict the calculator prints can be backed by the factor it exhibits or by agreement of methods with no known counterexamples at these sizes.
Why searchers bother
Exponential-form primes are the stress tests of computational number theory: each new record validates faster multiplication, better sieving and new proof techniques that then serve the whole field. Wagstaff numbers additionally interest researchers because their primality proofs exploit the form's algebraic structure - the same structure that forces composite exponents to fail - making them a clean laboratory for proof methods.
There is also the honest motive of the hunt itself. The exponent list below 200 took decades to complete; the list below 2,000 is a monument of distributed computing. A calculator that certifies the first seventeen exponents in milliseconds is standing on that accumulated work, and says so.
The new Mersenne conjecture
Wagstaff's name is also attached to the new Mersenne conjecture, formulated with Bateman and Selfridge, which predicts exactly when numbers of the Mersenne and Wagstaff forms can be prime simultaneously: roughly, the conditions on the exponent - being odd, prime, and of specific congruence types - cannot all align in certain combinations. The conjecture, if true, would organise both families' prime patterns into a single rule, and decades of computation have found no counterexample.
It is a characteristically Wagstaff situation: a clean statement, elementary to check case by case, resistant to proof. The seventeen exponents certified on this page all conform to the conjecture's predictions - a small, exact consistency check between a calculator and an open problem.
FAQs
What is a Wagstaff prime?
A prime of the form W(p) = (2^p + 1) / 3 with p prime - for example W(13) = 2,731.
Is W(13) prime?
Yes - W(13) = 2,731 is a Wagstaff prime, certified by both Miller-Rabin and Baillie-PSW tests.
Is 29 a Wagstaff prime exponent?
No. W(29) = 178,956,971 is composite, with smallest prime factor 59.
How many Wagstaff prime exponents are below 200?
17: 3, 5, 7, 11, 13, 17, 19, 23, 31, 43, 61, 79, 101, 127, 167, 191 and 199.
Why must the exponent be prime?
If p is composite, 2^p + 1 factors algebraically, so (2^p + 1) / 3 is automatically composite too.
What is the smallest Wagstaff prime?
W(3) = 3 itself.
How does the calculator prove primality?
By two independent methods that must agree: deterministic Miller-Rabin over twelve bases and a Baillie-PSW test (strong Miller-Rabin plus strong Lucas). Composites are convicted by an exhibited factor.
Are there infinitely many Wagstaff primes?
Conjectured yes, with the count growing like log log of the bound - but unproven, as for Mersenne primes.