Take the 2-minute tour ×
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.

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|improve this question
1  
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
1  
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

1 Answer 1

up vote 2 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|improve this answer
    
ah you answered as I was typing my answer :D –  Nikhil Bellarykar Jan 4 '12 at 14:50

Your Answer

 
discard

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.