Wednesday, October 11, 2006

is primitive root?

in Pari/GP this function tests if q is a primitive root (generator) of the field Zp.

isprimroot(q,p) = ff= factor(p-1); y=matsize(ff); for(i=1,y[1],if(Mod(1,p)==Mod(q,p)^((p-1)/ff[i,1]),return(0))); return(1)

No comments :