Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Theorem :

If Mersenne number can be uniquely written in the form : $x^2+3 \cdot y^2$ ,

where $\gcd(x,y)=1$ and $x,y \geq 0$ then that number is a prime number .

Primality test for Mersenne numbers written in Maple code :

enter image description here

My question : Why this test is considered to be less practical than Lucas-Lehmer primality test ?

share|cite|improve this question
If you are going to loop $x$ from $1$ to $\sqrt{2^p-1}$, why not just check if $x$ is factor? – Thomas Andrews Jan 4 '12 at 14:40
Your test is closely related to the so-called Fermat primality test, which does the same thing with $x^2+y^2$. The Fermat test can be pretty good at detecting nonprimes $n$ which can be expressed as $n=ab$ where $a$ and $b$ are close to each other. But its bad case running times are very large. – André Nicolas Jan 4 '12 at 14:47
up vote 3 down vote accepted

The number of iterations for your algorithm above is $\sqrt{N}$ where $N$ is the number to be tested, so it's no better than simple trial division (trying all the factors up to $\sqrt{N}$ to see if any of them are a divisor). On the other hand, the number of iterations Lucas-Lehmer test is (approximately) $p$ where $N=2^p-1$ is the number to be tested, so it takes only $\log N$ iterations.

share|cite|improve this answer
ah you answered as I was typing my answer :D – NikBels Jan 4 '12 at 14:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.