View Single Post
Old 2015-12-31, 13:52   #2
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

7×199 Posts
Default

A short and faster example, still in PARI-GP:
Code:
mylucas(p)={mp=2^p-1;
x=4;for(i=1,p-2,x=sqr(x);
hi=shift(x,-p);lo=bitand(x,mp);
x=lo+hi-2;
if(x>=mp,x-=mp);if(x<0,x+=mp));
return(x==0)}
R. Gerbicz is offline   Reply With Quote