Lucas-Lehmer primality test
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.eslintrc.js
.gitattributes
.gitignore
.travis.yml
LICENSE.txt
README.md
index.js
package.json

README.md

lucas-lehmer-test

Build Status Dependency Status

Lucas-Lehmer primality test in JavaScript. This is the primality test that is used by the Great Internet Mersenne Prime Search to locate large primes, and has done a pretty good job of finding some of the largest primes to date.

Example

Is the 31st Mersenne number a prime number?

var lucasLehmerTest = require('lucas-lehmer-test');

lucasLehmerTest(31);
// => true

Installation

$ npm install lucas-lehmer-test

API

var lucasLehmerTest = require('lucas-lehmer-test');

lucasLehmerTest(value)

Uses the Lucas-Lehmer primality test to determine if the valueth Mersenne number is a prime number. Returns true if it is; otherwise returns false. value can be a Number (it most cases it probably will be), a String (for really large numbers that JavaScript has a hard time with), or an instance of big-integer.