Created
March 10, 2012 09:59
-
-
Save dungpa/2011016 to your computer and use it in GitHub Desktop.
Lucas-Lehmer primality test for Mersenne numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lucasLehmer p = | |
let m = (1I <<< p) - 1I | |
let rec loop i acc = | |
if i = p-2 then acc | |
else loop (i+1) ((acc*acc - 2I)%m) | |
(loop 0 4I) = 0I |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment