KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesN+1 Tests and the Lucas-Lehmer TestEngineering · Engineering MathematicsLesson 853/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin JoginN+1 testLucas LehmerMersenne primeLucas sequence
On this page

Ask about this page

KEVOS AIN+1 Tests and the Lucas-Lehmer Test

KEVOS knowledge first · trusted web sources when needed

Classical Primality and Factoring

N+1 Tests and the Lucas-Lehmer Test

Primality tests using the factorisation of one more than the candidate, and the Lucas-Lehmer test for Mersenne numbers.

Engineering / MathematicsClassical Primality and Factoring2 min readKV-MATH-0651

The N+1 tests are the Lucas-sequence duals of Pocklington-Lehmer, using the factorisation of one more than the candidate. The Lucas-Lehmer test for Mersenne numbers is the celebrated special case.

The dual criterion

Where the N-1 test works in the multiplicative group modulo the candidate, the N+1 test works in the quadratic extension, where the relevant group has order one more than the candidate.

Key point

The two methods examine the two factors of the order of the multiplicative group of the quadratic extension, which is the product of one less and one more than the candidate. Between them they cover both, which is why the combination succeeds so much more often than either alone.

Combined tests

When neither one less nor one more can be factored sufficiently, combined criteria use partial factorisations of both. These extend the practical range considerably.

Choosing among classical proving methods
Available factorisationMethod
One less, past the square rootPocklington-Lehmer
One more, past the square rootN+1 test
Partial of bothCombined criteria, e.g. Brillhart-Lehmer-Selfridge
NeitherRequires a modern general method

Mersenne numbers

A Mersenne number is one less than a power of two. One more than it is a power of two, which is completely factored by inspection, so the N+1 machinery applies with no factoring work at all.

M_p = 2^p - 1, so M_p + 1 = 2^pCompletely factored, which is exactly what the N+1 test needs.

The Lucas-Lehmer test

For Mersenne numbers with prime exponent, the test reduces to a single recurrence: iterate a squaring map a fixed number of times and check whether the result vanishes.

The Lucas-Lehmer test

  1. StartBegin with the value four.
  2. IterateReplace by its square minus two, reduced modulo the Mersenne number.
  3. RepeatTwo fewer times than the exponent.
  4. TestThe number is prime exactly when the final value is zero.

Key point

This is a deterministic primality test with no probabilistic component and no factoring requirement, applicable only to Mersenne numbers. It is why the largest known primes are overwhelmingly Mersenne primes.

Why Mersenne numbers are efficient

Cost

Reduction modulo a Mersenne number is a shift and an add rather than a division, because the modulus is one less than a power of two. Combined with fast squaring by transform methods, this makes each iteration remarkably cheap — see fast multiplication.

Other special forms

Fermat numbers, Proth numbers and generalised Fermat numbers all admit similar specialised tests based on the structure of one more or one less than the candidate. Each rests on the same principle: a known factorisation on one side.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 8.4. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Related pages

  • The Pocklington-Lehmer N-1 Primality Test
  • Trial Division and Lehman's Method

Continue learning

The Pocklington-Lehmer N-1 Primality TestArticle · Engineering MathematicsNEXT LESSON →Trial Division and Lehman's MethodArticle · Engineering MathematicsThe Baillie-PSW Compositeness TestArticle · Engineering MathematicsThe Pollard Rho Factoring MethodArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®