Skip to content

Instantly share code, notes, and snippets.

@dungpa
Created March 10, 2012 09:59
Show Gist options
  • Save dungpa/2011016 to your computer and use it in GitHub Desktop.
Save dungpa/2011016 to your computer and use it in GitHub Desktop.
Lucas-Lehmer primality test for Mersenne numbers
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