- galois.is_primitive_root(g: int, n: int) bool
Determines if
is a primitive root modulo .See also
Notes¶
The integer
is a primitive root modulo if the totatives of , the positive integers that are coprime with , can be generated by powers of .Alternatively said,
is a primitive root modulo if and only if is a generator of the multiplicative group of integers modulo ,where
is order of the group.If
is cyclic, the number of primitive roots modulo is given by .Examples¶
In [1]: list(galois.primitive_roots(7)) Out[1]: [3, 5] In [2]: galois.is_primitive_root(2, 7) Out[2]: False In [3]: galois.is_primitive_root(3, 7) Out[3]: True