Input: 
n=p*q  integer  p,q primes,  p<<q
p smallest prime factor

Output:
The sequence of iterates x_i and y_i
The gcd(x_i-y_i)
The same sequences modulo the smallest factor p

For example: 
p=nextprime(10^4+546)
n=nextprime(10^4+546)*nextprime(10^10+765765)

NOTE: The gcd(x_i-y_i) is non trivial precisely when a coincidence occurs in Z_p



pollard2(n,p)=x=Mod(random,n);\
print("starting point is ", lift(x)); y=x;d=1;ii=0;\
while(d==1,\
ii=ii+1;x=x^2+2;y=y^2+2;y=y^2+2;d=d*(y-x);\
 print(lift(Mod(lift(x),n)),", ",lift(Mod(lift(y),n)),"   ", d=gcd(lift(d),n),"    ", lift(Mod(lift(x),p)),", ",lift(Mod(lift(y),p)));\
 d=gcd(lift(d),n));\
print(ii," steps: ",   ,"n=",d,"*",n/d)