Skip to content

Instantly share code, notes, and snippets.

@fujidig
Created February 4, 2016 09:57
Show Gist options
  • Select an option

  • Save fujidig/7f194fcac383aa0e8959 to your computer and use it in GitHub Desktop.

Select an option

Save fujidig/7f194fcac383aa0e8959 to your computer and use it in GitHub Desktop.
isprimitive(g, n)=
{
local(factors, p);
factors = factor(n);
for (i = 1, matsize(factors)[1],
p = factors[i, 1];
if (g^(n/p) == 1, return(0););
);
return(1);
}
f = Mod(x, Mod(1,2)*(x^1279+x^418+1))
print(if(isprimitive(f, 2^1279-1), "primitive", "not primitive"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment