Multiplicative Order Calculator
Find the smallest power that returns a number to one modulo n.
What it does
In modular arithmetic, multiplying a number by itself repeatedly eventually returns to one, provided the number and the modulus share no common factor. The multiplicative order is the number of steps in that cycle. It is written ord n of a and it is a fundamental idea in number theory and cryptography.
For a small modulus you can find the order by listing powers. Modulo 7 the powers of 3 are 3, 2, 6, 4, 5 and then 1, so the order is 6. The tool does the same thing with modular multiplication, avoiding the enormous integers that direct exponentiation would create.
The coprime condition is essential. If a and n share a factor, no power of a can be congruent to one, because every power keeps that factor. The tool checks the greatest common divisor first and returns a clear error when the condition fails.
Euler's totient function counts how many numbers below n are coprime to it. A theorem of Lagrange says the order divides that count. The tool prints the totient beside the order so you can check the relationship. For a prime modulus the totient is n minus one, which makes the check simple.
Multiplicative order appears in primality tests, in the analysis of repeating decimals and in the design of cryptographic groups. This page computes the order only. It does not find primitive roots or solve discrete logarithms, which are related but separate problems.
How to use
- Enter the base a, which may be negative or larger than the modulus.
- Enter a modulus n between 2 and 1,000,000.
- Check that the tool did not report a coprimality error.
- Read the order and the totient of n.
- Confirm that the order divides the totient.
- Try another coprime base to see a different cycle length.
Formula
- a
- The base, reduced modulo n before multiplication.
- n
- The modulus, an integer of at least 2.
- k
- The exponent being tested, starting at 1.
- ord_n(a)
- The smallest exponent that returns one.
- gcd
- Greatest common divisor, which must equal 1.
The tool tests exponents only up to the totient of n, which is a proven bound for the order when a and n are coprime. Modular reduction after each multiplication prevents overflow. Negative bases are reduced into the range from zero to n minus one first.
Worked example
Example: base 3 modulo 7
Defaults: a = 3 and n = 7.
- Check gcd(3, 7) = 1, so the order exists.
- 3 to the power 1 is 3 modulo 7.
- 3 to the power 2 is 9, which is 2 modulo 7.
- 3 to the power 3 is 6 modulo 7.
- Continuing gives 4, then 5, then 1 at the sixth power.
- The tool shows order 6, totient 6 and 6 steps to one.
Reference table
| Base | Order | Totient of 7 |
|---|---|---|
| 1 | 1 | 6 |
| 2 | 3 | 6 |
| 3 | 6 | 6 |
| 4 | 3 | 6 |
| 5 | 6 | 6 |
| 6 | 2 | 6 |
Limits
- Only defined when the base and modulus are coprime.
- The modulus is limited to 1,000,000 to keep the search quick.
- Computes the order, not a primitive root or a discrete logarithm.
- Does not display the full sequence of powers, only the first return to one.
Common mistakes
- Entering a base that shares a factor with the modulus.
- Assuming the order always equals the totient.
- Confusing the order with the number of coprime residues below n.
- Using the order as if it were the base itself.
- Expecting a result for a modulus of one.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is the order of 2 modulo 7?
The powers are 2, 4 and then 1, so the order is 3. The totient of 7 is 6 and 3 divides 6.
Find the order of 2 modulo 9.
The powers are 2, 4, 8, 7, 5 and 1, so the order is 6. The totient of 9 is also 6.
What happens with base 4 and modulus 8?
The tool returns the error a and n must be coprime, because their greatest common divisor is 4 and no power of 4 can be one modulo 8.
Questions
What is multiplicative order?
It is the smallest positive exponent that makes a power of a number equal to one in modular arithmetic.
Why must the numbers be coprime?
Any shared factor persists through every power, so a power can never be congruent to one modulo the shared modulus.
How does the order relate to the totient?
The order always divides Euler's totient of the modulus, which is the size of the multiplicative group.
Does a larger modulus mean a larger order?
Not necessarily. The order depends on how the base sits inside the group rather than only on the size of the modulus.
Can the base be negative?
Yes. The tool reduces it into the valid range before multiplying, so the order is the same as for its positive residue.
Where is this used?
It appears in primality testing, periodic decimal expansion and the analysis of cryptographic groups.
Sources
- Texas A&M University, MATH 433 Applied Algebra, Lecture 10
- Stanford University, Number Theory: The Order of a Unit