What's wrong with my code? It doesn't work inside Sage Math Cell.
gp.eval("xmat(r,n) = [2*x, -1; 1, 0]*Mod(1,x^r-1)*Mod(1,n);")
gp.eval("smallestr(n)={if(n==1 || n%2==0, return(0));forprime(r = 3, oo,my(u=n%r);if (u==0 && r < n, return(0));if (u!=0
&& u!=1 && u!=r-1, return(r)));}")
gp.eval("myisprime(n)={my(r = smallestr(n));if (r == 0, return(n == 2));my(xp = xmat(r,n)^n*[x,1]~);xp[2] ==
Mod(x*Mod(1,n),x^r-1)^n;}")
def Check(n):
if gp.function_call("myisprime",[n]).sage()==true:
return ("Prime!")
else:
return ("Composite!")
@interact
def _(n=2017,action=selector(['Check'],buttons=True,label='')):
action = eval(action)
print (action())
I am getting the following message: TypeError: Check() missing 1 required positional argument: 'n'