Artificial intelligent assistant

Infinite generation of primes I understand the prime sieves find primes less than a value, say _n_. I also know that trial division is woefully inefficient for any sort of large number. Is there any way of efficiently finding primes, without the arbitrary limit that a sieve needs to work? A function to generate primes continuously.

There is no exact way to generate primes continuously.

Though there is ways better than others. That's why almost all the big primes we find nowadays are Mersenne primes, which are primes of the form

$$2^p-1$$

where $p$ is also a prime number. We do that because Mersenne numbers have a very efficient criteria to determine whether or not they are prime. It is called Lucas primality test.

For Lucas primality test, you take a Mersenne number, and you have to check that:

$$\forall q\mid p-1,\quad 2^{(p-1)/q}\
ot\equiv 1 \pmod p.$$

If a number passes the test, then it is a prime number.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a0da7e2a76e79cb5ce500a6c394702d2