Test of primality

A test of primality is a algorithm making it possible to know if a Integer is first.

Naive method

The simplest test is the following: to test NR , it is checked if it is divisible by one of the entireties ranging between 2 and N/2 (terminals included/understood). If the answer is negative, then NR is first, if not it is made up.

Several changes make it possible to improve the performances of this algorithm:

  • it is enough to only test all the numbers of 2 with \ sqrt {NR} , since if N = pq then either p \ Leq \ sqrt {NR} or q \ Leq \ sqrt {NR} ,
  • one can still divide by two work into testing only the odd numbers, once divisibility by two failed,
  • in a general way, one can calculate in advance a list of the prime numbers lower than a limit (with a Crible of Ératosthène), to test only those (or 46 tests for the numbers lower than 39000, for example).

Probabilistic tests

The probabilistic tests are not tests of primality in a strict sense: they do not make it possible to be ensured in an unquestionable way that a number is first, but are acceptable for practical applications such as the Cryptologie which often depends in a critical way of the great prime numbers. They however are very much used whenever a low level of error is acceptable: they are called prime numbers industrialists . The basic idea is the following one:

  1. Prendre by chance a number has .

  2. Vérifier a certain equality between has and the number given NR . If the equality fails, then NR is a made up Nombre, has is known like a pilot for the composition, and the test stops.
  3. To repeat stage 1 until the necessary certainty is completed.

After several iterations, if NR is not recognized like a made up Nombre, then he is declared probably first .

These tests are fast but often imperfect. For a given test, it can exist certain made up numbers which will be declared “probably first” whatever the witness. Such numbers are called numbers pseudopremiers for this test.

The simplest test of the probabilistic primality is the Test of primality of Fermat. It is some time used if a fast posting of the numbers is necessary, for example, in the phase of generation of key of the algorithm of cryptography to public key '' RSA ''. The Test of primality of Miller-Rabin and the Test of primality of Solovay-Strassen are more sophisticated alternatives which detect all the compounds; they are often methods of choice.

Fast deterministic tests

A deterministic test of primality is the cyclotomic Test; its execution time can be proven as being of O ( N C log (log ( N ))), where N is the number of figures of NR and C is a Constante independent of N . It is slower than the polynomial Temps.

The Test of elliptic primality of curve can be shown as being of execution O ( N 6), but only so certain statements of analytical Théorie of the numbers not yet shown (but largely accepted as true) are used. In practice, this test is slower than the cyclotomic test for the numbers comprising more than 10.000 digits.

The implementation of these two methods is rather difficult, and their probabilities of error in practice can be consequently much higher than those of the probabilistic methods mentioned above.

If the Hypothèse of Riemann generalized is true, the test of Miller-Rabin can be converted into a deterministic version with an execution time Õ ( N 4). In practice, this algorithm is slower than the two precedents for sizes of numbers which can be treated by them.

In 2002, Manindra Agrawal, Nitin Saxena and Neeraj Kayal described a new test of deterministic primality which is carried out in Õ ( N 12), and this terminal can be shown rigorously. Moreover, this conjecture given like not shown, but largely recognized like true, it would be carried out in Õ ( N 6). Like such, that provides the first deterministic test of primality with a polynomial time execution. In practice, this algorithm is slower than the other methods.

Theoretical methods of the numbers

Certain theoretical methods of the numbers exist, such as the test of Lucas-Lehmer to test if a number is first. The test of Lucas-Lehmer is connected to the fact that the multiplicative Ordre of a certain number has modulo N is N -1 for a prime number N when has is a primitive root. If we can show that has is a primitive root for N , we can show that N is first.

Simple: Primality test

Random links:Ponds | Scapa Flow | San Fernando del Valle de Catamarca | Reading order of the news of Elric | 1883 with the theater | Janv._Karon