Lucas - Lehmer Residuals

Helmut Knaust, Department of Mathematical Sciences, UTEP, El Paso TX 79968
hknaust@utep.edu
10/12/08

LucasLehmerResiduals[p_]:=(s[0]=4;s[n_]:=s[n]=Mod[s[n-1]^2-2,2^p-1];If[Not[PrimeQ[p]],Print["Warning: ",p,"  is not a prime."],Print[Table[{n,s[n]},{n,0,p-2}]//TableForm];If[s[p-2]==0,Print[HoldForm[2^p-1]," = ",2^p-1," is a Mersenne prime."],Print[HoldForm[2^p-1]," = ",2^p-1," is not a Mersenne prime."]]];Print["\n"];Clear[s])

LucasLehmerResiduals[13]

Do[LucasLehmerResiduals[Prime[n]],{n,2,50}]