your task is to write a program that uses the Lucas-Lehmer primality test to check whether an input number is prime or not. This prime number candidate has the form
2p-1 with p being prime. (Mersenne prime number)
The n-th Mersenne number is prime if it is a divisor of the (n-1)-th Lucas-Lehmer number (LLN). You can calculate the LLN, similiar to the Fibonacci numbers, based on a recursive algorithm:
L<n> = (L<n-1>)^2 - 2
The LLN for 2 is 14. So, for p=3, LLN<3-1>=14
- You have to submit a function that takes p as input (Remember:
- The shortest solution will win.
- Your solution has to use the Lucas-Lehmer test
- The code must be executable.
- Output: boolean value or 1=prime/0=not prime
p --> 2^p-1 --> LLN<n-1> --> ? 3 --> 7 --> 14 --> prime 5 --> 31 --> 37634 > prime (1214*31)