MyVIPWebTools logo

Primitive Root Calculator — Find the Smallest Primitive Root Modulo n

Our Primitive Root Calculator finds the smallest primitive root modulo n — an integer g whose powers g¹, g², g³, ... cycle through every unit modulo n before repeating. It first checks whether a primitive root exists at all (they only exist for n = 1, 2, 4, pᵏ, or 2pᵏ for an odd prime p), then searches using Euler's totient function and its prime factorization to test each candidate efficiently.

Quick Answer

A primitive root g mod n generates every unit modulo n via its powers. Enter n below to find the smallest one, with an automatic check for whether a primitive root exists at all.

Enter n, then click Calculate.

How to Use the Primitive Root Calculator — Find a Generator mod n

  1. 1

    Enter a positive whole number n (up to 1,000,000).

  2. 2

    Click 'Calculate' to find the smallest primitive root modulo n, if one exists.

  3. 3

    Review φ(n) and the prime factors of φ(n) used in the verification.

Why Use Primitive Root Calculator — Find a Generator mod n?

A primitive root modulo n is a generator of the group of integers coprime to n under multiplication: its successive powers produce every unit modulo n exactly once before cycling back to 1, at exactly φ(n) steps. Not every n has one — primitive roots only exist for n = 1, 2, 4, an odd prime power pᵏ, or twice an odd prime power 2pᵏ, a classical result in number theory. This calculator checks that condition first, then efficiently verifies each candidate g by testing g^(φ(n)/q) mod n for every prime factor q of φ(n) — g is a primitive root exactly when none of those tests equal 1.

Frequently Asked Questions

Related Tools

Primitive Root Calculator — Find a Generator mod n | MyVIPWebTools