ISPRIMROOT

This function tests whether a is a primitive root modulo p. A value is a primitive root when it generates the entire multiplicative group of units modulo p.

Equivalently, a must satisfy:

\gcd(a,p)=1 \quad \text{and} \quad \operatorname{ord}_p(a)=\varphi(p)

Primitive roots exist only for moduli in specific families, so many moduli return false for all candidates.

Excel Usage

=ISPRIMROOT(a, p)
  • a (int, required): Candidate generator value.
  • p (int, required): Modulus greater than one.

Returns (bool): True if a is a primitive root of p, otherwise False.

Example 1: Primitive root true case modulo ten

Inputs:

a p
3 10

Excel formula:

=ISPRIMROOT(3, 10)

Expected output:

true

Example 2: Primitive root false case modulo ten

Inputs:

a p
9 10

Excel formula:

=ISPRIMROOT(9, 10)

Expected output:

false

Example 3: Primitive root true case modulo prime

Inputs:

a p
2 11

Excel formula:

=ISPRIMROOT(2, 11)

Expected output:

true

Example 4: Primitive root false case modulo prime

Inputs:

a p
4 11

Excel formula:

=ISPRIMROOT(4, 11)

Expected output:

false

Python Code

from sympy import is_primitive_root as sympy_is_primitive_root

def isprimroot(a, p):
    """
    Check whether a value is a primitive root modulo n.

    See: https://docs.sympy.org/latest/modules/ntheory.html#sympy.ntheory.residue_ntheory.is_primitive_root

    This example function is provided as-is without any representation of accuracy.

    Args:
        a (int): Candidate generator value.
        p (int): Modulus greater than one.

    Returns:
        bool: True if a is a primitive root of p, otherwise False.
    """
    try:
        return bool(sympy_is_primitive_root(a, p))
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Candidate generator value.
Modulus greater than one.