testgcd = (f,g)->( h:=f; s:=g; while s!=0 do ( rem:= h%s; h =s; s =rem ); return h) testgcd(3,4) testgcd(12,18) R=ZZ/101[x] f=(x^2+1)^3*(x^20+x^3+35*x+1) g=(x^2+1)^2*(x^21+x^5+3*x+21) testgcd(f,g) gcd(f,g) R=QQ[x] f=(x^2+1)^3*(x^20+x^3+35*x+1) g=(x^2+1)^2*(x^21+x^5+3*x+21) testgcd(f,g) gcd(f,g)