Lucas-Lehmer Test for Mersenne Primes

M. Gallant 1/2016

This applet implements the Lucas-Lehmer method for testing the primality of a Mersenne number. Mersenne numbers are of the form:
2^p-1

where p is odd. In fact, it can easily be shown that for 2^p-1 to be prime, the exponent p must also be prime.

Mersenne primes are of particular interest because they represent the largest known primes to date, and the primality test is easily implemented on supercomputers. Currently [1/2016], the largest known prime number is the Mersenne prime 2^74,207,281-1 discovered by GIMPS on 1/2016.) Since Java 1.1+ supports BigInteger arbitrary-precision math, it is easy to implement the Lucas-Lehmer test in Java. Enter a range of values for the exponent p of the Mersenne numbers in the text-fields below, (the first number must be odd) and click Test for Primes. Click Print to display the value of the Mersenne number shown in the second upper right text field:


A similar standalone Java application version is available.