0
$\begingroup$

I would like to implement the Pollard p-1 algorithm in Pari/GP but I failed. Here is my code. I am confused with when should I use "," and when should I use ";" in for loop and if statement.

n=2993

b=2

maxk=100

for(i=1,maxk,b=Mod(b^i,n);if(Mod(i,10)==0,g=gcd(b-1,n );if(g>1,print(g),break));print("1"))

and here is the algorithm: enter image description here

$\endgroup$
1
  • $\begingroup$ a=0; for(i=1,N,{ a = a*i; print(i); if (a > 10, {print(a); break;})}); $\endgroup$
    – reuns
    Oct 8, 2017 at 23:34

1 Answer 1

1
$\begingroup$

Here the code (in the example, a factor of $2^{67}-1$ is searched)

? n=2^67-1;x=3;s=1;while(gcd(x-1,n)==1,s=s+1;x=lift(Mod(x,n)^s));print(gcd(x-1,n
))
193707721
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .