OFFSET
0,1
COMMENTS
Since a(29) = 0, M(31) = 2147483647 is prime. Mersenne numbers are only prime if a(p-2) = 0.
LINKS
Dennis Martin, Table of n, a(n) for n = 0..29
Eric Weisstein's World of Mathematics, Lucas Lehmer Test.
Wikipedia, Lucas Lehmer Primality Test.
FORMULA
a(0) = 4, a(n) = a(n-1)^2 mod 2^p-1. Last term: a(p-2).
EXAMPLE
a(29) = 65536^2 - 2 mod 2147483647 = 0.
PROG
(Python)
p = 31; Mp = 2**p - 1
from itertools import accumulate
def f(anm1, _): return (anm1**2 - 2) % Mp
print(list(accumulate([4]*30, f))) # Michael S. Branicky, Apr 14 2021
CROSSREFS
KEYWORD
fini,nonn
AUTHOR
Sergio Pimentel, Apr 04 2007
STATUS
approved