Lucas-Lehmer test

from Wikipedia, the free encyclopedia
Detail from page 316 of the work Théorie des Fonctions Numériques Simplement Périodiques by Édouard Lucas (1878)

The Lucas-Lehmer test is a prime number test for Mersenne numbers , that is, for numbers of the form . The test is used in the GIMPS project ( Great Internet Mersenne Prime Search ) - the search for previously unknown Mersenne prime numbers.

This test is based on properties of the Lucas sequences and not, like the Lucas test, on Fermat's little theorem .

functionality

The Lucas-Lehmer test is suitable for testing Mersenne numbers from . It is essentially based on the fact that the Mersenne numbers in the dual system (binary system) consist only of ones.

The Mersenne prime number is a prime number that is written exclusively with the binary digit "1".
binary 11 111 11111 1111111 1111111111111 11111111111111111 1111111111111111111 1111111111111111111111111111111 ...
power 2 2 −1 2 3 −1 2 5 −1 2 7 −1 2 13 −1 2 17 −1 2 19 −1 2 31 −1 ...
decimal 3 7th 31 127 8,191 131,071 524.287 2,147,483,647 ...
The most important property of a Mersenne prime number: "The number of binary digits must be a prime number."

The Mersenne number is a binary number that consists of ones ( repunit , palindrome of numbers ).

The Lucas-Lehmer test works as follows:

Be odd and prime. The consequence is defined by .
Then: is a prime number if and only if is divisible by .

This sentence was found in 1930 by Derrick Henry Lehmer and goes back to Édouard Lucas (see illustration). With the help of the modulo function mod, the sentence can be formulated as follows:

Be and . Then: is a prime number if and only if .

Examples

Example 1: We use this procedure to check whether a number is prime:

 S(1) = 4
 S(2) = ( 4² - 2) mod 31 =  14 mod 31 = 14
 S(3) = (14² - 2) mod 31 = 194 mod 31 = 8
 S(4) = ( 8² - 2) mod 31 =  62 mod 31 = 0

There is is a prime number.

Example 2: We check whether a number is prime:

 S( 1) = 4
 S( 2) = (   4² - 2) mod 2047 =      14 mod 2047 = 14
 S( 3) = (  14² - 2) mod 2047 =     194 mod 2047 = 194
 S( 4) = ( 194² - 2) mod 2047 =   37634 mod 2047 = 788
 S( 5) = ( 788² - 2) mod 2047 =  620942 mod 2047 = 701
 S( 6) = ( 701² - 2) mod 2047 =  491399 mod 2047 = 119
 S( 7) = ( 119² - 2) mod 2047 =   14159 mod 2047 = 1877
 S( 8) = (1877² - 2) mod 2047 = 3523127 mod 2047 = 240
 S( 9) = ( 240² - 2) mod 2047 =   57598 mod 2047 = 282
 S(10) = ( 282² - 2) mod 2047 =   79522 mod 2047 = 1736

There is is not a prime number (it holds ).

Example 3: We check whether a number is prime:

 S( 1) = 4
 S( 2) = (      4² - 2) mod 524287 =     14
 S( 3) = (     14² - 2) mod 524287 =    194
 S( 4) = (    194² - 2) mod 524287 =  37634
 S( 5) = (  37634² - 2) mod 524287 = 218767
 S( 6) = ( 218767² - 2) mod 524287 = 510066
 S( 7) = ( 510066² - 2) mod 524287 = 386344
 S( 8) = ( 386344² - 2) mod 524287 = 323156
 S( 9) = ( 323156² - 2) mod 524287 = 218526
 S(10) = ( 218526² - 2) mod 524287 = 504140
 S(11) = ( 504140² - 2) mod 524287 = 103469
 S(12) = ( 103469² - 2) mod 524287 = 417706
 S(13) = ( 417706² - 2) mod 524287 = 307417
 S(14) = ( 307417² - 2) mod 524287 = 382989
 S(15) = ( 382989² - 2) mod 524287 = 275842
 S(16) = ( 275842² - 2) mod 524287 =  85226
 S(17) = (  85226² - 2) mod 524287 = 523263
 S(18) = ( 523263² - 2) mod 524287 =      0

There is is a prime number (this has been known since 1603).

Example implementation in Python

The following program implements the Lucas-Lehmer test in the Python programming language . In Python it is possible to calculate with arbitrarily large whole numbers that are only limited by the available memory. The implementation presented here does not take into account that the Lucas-Lehmer test ideally breaks off when it is even or not prime, this is left to the user. If you entered the program would give the wrong statement that the number 3 is not a Mersenne prime number.

Postmark for the discovery of the Mersenne prime number 2 11213 -1

On an Intel Pentium 4 from 2005, the calculation for this program only takes 41 seconds. The calculation in 1963, with which it was proven that is prime, took another 2¼ hours with a supercomputer Illiac II at the time .

#Lucas-Lehmer-Test fuer Python 3
print('Lucas-Lehmer-Test (Mersenne-Zahlen)')
p = int(input('Exponent p von 2^p-1 '))
m = 2 ** p-1
print('m = 2 ^', p, '- 1 =', m)
s = 4
for i in range (2, p):
    s = (s * s - 2) % m
print('ist {}eine Mersenne-Primzahl'.format('' if s == 0 else 'k'))

literature

Individual evidence

  1. For proof, see Ribenboim: Die Welt der Prime numbers , pp. 78/79.
  2. ILLIAC II in the English language Wikipedia
  3. ^ Donald B. Gillies: Three new Mersenne primes and a statistical theory