This is an implementation of the pollard-rho factorization-algorithm in sage (filename: exp.sage)

```
def pollard_rho(n):
x = 2
y = x
t = 1
while t == 1:
x = mod(x,n)^2+1
y = mod(mod(y,n)^2+1,n)^2+1
t = gcd(x-y,n)
if t<n:
return(t)
else:
return 0
```

I load it with "`load exp.sage`

" and it works.

But trying to compile

```
import sage.all
def pollard_rho(n):
x = 2
y = x
t = 1
while t == 1:
x = sage.all.mod(x,n)**2+1
y = sage.all.mod(sage.all.mod(y,n)**2+1,n)**2+1
t = sage.all.gcd(x-y,n)
if t<n:
return(t)
else:
return 0
```

named as "`exp.spyx`

" brings several errors, one of them (f.e.):

```
13 while t == 1:
14 x = sage.all.mod(x,n)**2+1
---> 15 y = sage.all.mod(sage.mod(y,n)**2+1,n)**2+1
16 t = sage.all.gcd(x-y,n)
17
AttributeError: 'module' object has no attribute 'mod'
```

What is wrong here? Probably many things - im totally new to Sage, coming from Pari-gp and work in console-mode - no experiences with C or Python. Thank you.