Lucas-Lehmer test
Lucas-Lehmer Test: for $p$ an odd prime, the Mersenne number $2^p-1$ is prime if and only if $2^p-1$ divides $S(p-1)$ where $S(n+1)=(S(n))^2-2$, and $S(1)=4$.
Test
{{test}}Console output
                
              
            Lucas-Lehmer Test: for $p$ an odd prime, the Mersenne number $2^p-1$ is prime if and only if $2^p-1$ divides $S(p-1)$ where $S(n+1)=(S(n))^2-2$, and $S(1)=4$.
                
              
            Use Cmd instead of Ctrl if you're on a Mac.
| g | Focus editor | 
| Ctrl-Enter | Run the test with current code | 
| Ctrl-Shift-K | Reset the editor | 
| Ctrl-Shift-L | Clear console output | 
| Ctrl-Shift-X | Show the solution | 
| [ | Previous challenge | 
| ] | Next challenge | 
| T | Back to top page | 
| ? | Show this dialog | 
| ESC | Hide this dialog | 
| Shift-ESC | Blur focus from editor |