Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is a sample code that iterates over the roots of cyclotomic polynomial until it finds a primitive one:

F = GF(12206081)
m = 16384
P = prime_divisors(m)
primitive_root = next(r for r in cyclotomic_polynomial(m).roots(F,multiplicities=False) if all(r^(m//p)!=F.one() for p in P))

Here is a sample code that iterates over the roots of cyclotomic polynomial until it finds a primitive one:

p = 12206081
F = GF(12206081)
GF(p)
m = 16384
P = prime_divisors(m)
primitive_root prim_root = next(r for r in cyclotomic_polynomial(m).roots(F,multiplicities=False) if all(r^(m//p)!=F.one() for p in P))

A faster way is just to take a primitive root modulo $p$ and raise it to the power $(p-1)/m$:

p = 12206081
m = 16384
assert (p-1)%m == 0
prim_root = Mod(primitive_root(p),p)^((p-1)//m)