← LibraryLucas Sequences and Lucas PseudoprimesEngineering · MathematicsLesson 351/385← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin JoginLucas sequenceLucas testprobable primecomplementary test

Classical Primality and Factoring

Lucas Sequences and Lucas Pseudoprimes

Lucas sequences, the Lucas probable prime test, and why it complements the strong pseudoprime test rather than duplicating it.

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

Lucas sequences give a primality test based on a quadratic recurrence rather than on modular exponentiation. Its failure modes are different from those of the strong test, which is what makes the combination valuable.

Lucas sequences

Given parameters defining a quadratic, two integer sequences satisfy the associated linear recurrence. The Fibonacci numbers are the simplest instance.

U_(k+1) = P U_k - Q U_(k-1), similarly for VP and Q the parameters; the discriminant is P squared minus 4Q.

The test

For a prime not dividing the discriminant, a specific term of the sequence must vanish modulo that prime, with the index determined by the Jacobi symbol of the discriminant.

U_(n - (D/n)) = 0 (mod n) for prime nThe Jacobi symbol determines the index.

Why it complements the strong test

The two tests examine different structure
TestWorks inFailure mode
Strong pseudoprimeThe multiplicative group modulo nComposites with particular multiplicative structure
LucasA quadratic extensionComposites with particular quadratic structure

Parameter selection

The parameters must be chosen so the discriminant is a non-residue modulo the candidate. Selmer's method scans a fixed sequence of candidate discriminants and takes the first with Jacobi symbol minus one.

Strong Lucas test

As with the Fermat test, a strong version exists that additionally examines the sequence of intermediate values. It is stronger and costs little more, and it is what Baillie-PSW actually uses.

Cost

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 8.3. 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.

Continue learning

Fermat and Strong Pseudoprime TestsArticle · MathematicsNEXT LESSON →The Baillie-PSW Compositeness TestArticle · MathematicsPrimality Versus Factoring: Framing the ProblemsArticle · MathematicsThe Pocklington-Lehmer N-1 Primality TestArticle · Mathematics