Maple Program.
main:=proc()
local p,s,n,m;
with(numtheory);
p:=61;
m:=(2^p)-1;
s:=4;
for n from 2 by 1 to p-1 do
s:=((s*s)-2) mod m;
print(s);
od;
end;
The theory for this test was initiated by Lucas
in the late 1870's and then made into this simple test about 1930 by
Lehmer. The sequence S(n) is computed modulo
2p-1 to save time. This test is ideal for binary
computers because the division by 2p-1 (in binary) can
be done using rotation and addition only.