Staaarter

Generate Lucas Primes

Generates the first N Lucas numbers that are also prime numbers, searching forward through the Lucas sequence and testing each term with a Miller-Rabin primality test. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
fibonacciprimes

Overview

Introduction

The Lucas sequence shares the Fibonacci sequence's addition rule but starts from different seed values, and like the Fibonacci sequence, only some of its terms turn out to be prime.

This tool searches forward through the Lucas sequence, testing each term for primality, and returns the first N that qualify.

What Is Generate Lucas Primes?

A generator that filters the Lucas sequence down to only the terms that are also prime numbers: 2, 3, 7, 11, 29, 47, 199, and so on.

It combines Lucas term generation with a Miller-Rabin primality test capable of handling the hundreds-of-digits-long numbers that appear deeper in the sequence.

How Generate Lucas Primes Works

The tool walks the Lucas sequence term by term using BigInt arithmetic, starting from L(0) = 2 and L(1) = 1, testing each term for primality as it's produced.

Primality testing first rules out small prime factors directly, then applies a Miller-Rabin test with a fixed set of witness bases for larger candidates; qualifying terms are collected until N have been found or the search range is exhausted.

When To Use Generate Lucas Primes

Use it whenever you need the specific subsequence of Lucas numbers that are prime, for number theory coursework, puzzle-solving, or comparing against Fibonacci primes.

If you just need plain Lucas numbers without the primality filter, use Lucas Number Generator instead.

Features

Advantages

  • Handles the large numbers involved correctly, Lucas terms in the hundreds of digits are tested exactly as reliably as small ones.
  • Saves the work of generating a Lucas sequence yourself and manually checking each term for primality.
  • Searches automatically as far as needed within its range, you just specify how many results you want.

Limitations

  • Capped at 20 results, since known Lucas primes become sparse and the search has to stay within a range that resolves in a reasonable time.
  • Uses Miller-Rabin, a probabilistic primality test, though the fixed witness set used here is exact for every number size this tool can produce.

Examples

First 5 Lucas primes

Input

5

Output

2, 3, 7, 11, 29

These are the Lucas numbers at indices 0, 2, 4, 5, and 7 that also happen to be prime.

First 8 Lucas primes

Input

8

Output

2, 3, 7, 11, 29, 47, 199, 521

Best Practices & Notes

Best Practices

  • Keep expectations realistic about count size, Lucas primes thin out quickly, so this isn't a tool for generating hundreds of them.
  • If the search reports it couldn't find enough terms, try a smaller count rather than assuming something's broken, it means the next Lucas prime lies beyond the tool's search range.

Developer Notes

The Miller-Rabin implementation uses the fixed witness set {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}, which is deterministic for every integer well beyond the size the Lucas sequence reaches within this tool's search cap of 1000 indices; combined with that hard search cap, worst-case runtime stays bounded no matter what count is requested.

Generate Lucas Primes Use Cases

  • Studying which Lucas numbers are also prime for number theory coursework
  • Generating known Lucas-prime reference values for testing a primality-testing implementation
  • Comparing Lucas primes against Fibonacci primes to see how the two closely related sequences diverge

Common Mistakes

  • Requesting a count well above 20 expecting it to just take longer, the tool caps the count outright rather than let a search run indefinitely.
  • Assuming the Lucas prime and Fibonacci prime lists share most of their values, they only rarely coincide since the two sequences are seeded differently.

Tips

  • Compare this list against Fibonacci Prime Generator to see how the two closely related sequences differ in which terms are prime.
  • Cross-check a specific value against Prime Number Checker if you want to confirm a term is prime independent of its Lucas origin.

References

Frequently Asked Questions