galois.mersenne_exponents

galois.mersenne_exponents(n: int | None = None) list[int]

Returns all known Mersenne exponents \(e\) for \(e \le n\).

A Mersenne exponent \(e\) is an exponent of \(2\) such that \(2^e - 1\) is prime.

Parameters
n: int | None = None

The max exponent of 2. The default is None which returns all known Mersenne exponents.

Returns

The list of Mersenne exponents \(e\) for \(e \le n\).

See also

mersenne_primes

References

Examples

# List all Mersenne exponents for Mersenne primes up to 2000 bits
In [1]: e = galois.mersenne_exponents(2000); e
Out[1]: [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279]

# Select one Merseene exponent and compute its Mersenne prime
In [2]: p = 2**e[-1] - 1; p
Out[2]: 10407932194664399081925240327364085538615262247266704805319112350403608059673360298012239441732324184842421613954281007791383566248323464908139906605677320762924129509389220345773183349661583550472959420547689811211693677147548478866962501384438260291732348885311160828538416585028255604666224831890918801847068222203140521026698435488732958028878050869736186900714720710555703168729087

In [3]: galois.is_prime(p)
Out[3]: True

Last update: Apr 21, 2022