Lucas-Lehmer test for Mersenne numbers (Haskell)

From LiteratePrograms

Jump to: navigation, search
Other implementations: Erlang | Haskell | J | Java | Lisp | Python | Ruby | Scheme

This program is a code dump.
Code dumps are articles with little or no documentation or rearrangement of code. Please help to turn it into a literate program. Also make sure that the source of this code does consent to release it under the MIT or public domain license.


lucasLehmer p | p < 2     = False
              | otherwise = iterate f 4 !! (p-2) == 0
  where f s = (s * s - 2) `mod` m
        m = 2 ^ p - 1
Download code
Views