isPrimitiveRoot

Tests whether a is a primitive root modulo n.

Category: Mathematics > Number Theory

Syntax

tf = isPrimitiveRoot(a, n)

Returns logical true where a is a primitive root modulo n.

Description

An integer a coprime to n is a primitive root modulo n when its powers run through every residue coprime to n, that is when the multiplicative order of a equals eulerPhi(n). Primitive roots exist only for n equal to 1, 2, 4, p^k or 2*p^k with p an odd prime.

Modulo 7 the primitive roots are 3 and 5.

Input arguments

a
Integer scalar or array of candidates.
n
Positive integer modulus.

Output arguments

tf
Logical array of the size of a.

Example

Candidates modulo 7

isPrimitiveRoot(1:6, 7)
isPrimitiveRoot(2, 7)
Output
ans = 1×6 logical array

   0   0   1   0   1   0
ans = logical
   0

See also

eulerPhi jacobiSymbol mod isprime