Search for a tool
Multiplicative Order

Tool to calculate the multiplicative order of an integer modulo n, find the smallest exponent k such that a^k is congruent to 1 modulo n, and study the arithmetic properties of powers modulo an integer.

Results

Multiplicative Order -

Tag(s) : Arithmetics

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Multiplicative Order' tool for free! Thank you!

Multiplicative Order

Multiplicative Order Calculator

$$ a^? \equiv 1 \mod n $$



Answers to Questions (FAQ)

What is the multiplicative order? (Definition)

The multiplicative order of $ a $ modulo $ n $ is the smallest strictly positive integer $ k $ such that $ a^k \equiv 1 \pmod{n} $.

The multiplicative order measures the length of the cycle traced by a number raised to its successive powers modulo another number. Raising an integer $ a $ to successive powers modulo an integer $ n $ will always eventually return to 1, provided that $ a $ and $ n $ are coprime. The powers $ a^1, a^2, a^3, \ldots $ describe a closed cycle in the set of residues modulo $ n $, and the order is the length of this cycle: it is the arithmetic analogue of the period of a periodic function.

Example: The powers of $ 3 \mod 7 $ give $ 3, 2, 6, 4, 5, 1, 3, 2, \ldots $; the order of $ 3 $ modulo $ 7 $ is denoted $ \operatorname{ord}_7(3) = 6 $, since $ 3^6 \equiv 1 \pmod{7} $ and no smaller exponent works.

What is the formal definition of the multiplicative order?

Let $ n \geq 2 $ and $ a $ be an integer invertible modulo $ n $, i.e. coprime to $ n $. The multiplicative order of $ a $ modulo $ n $, denoted $ \operatorname{ord}_n(a) $, is defined by $ \operatorname{ord}_n(a) = \min\{k \in \mathbb{N}^* : a^k \equiv 1 \pmod{n}\} $.

Why is the invertibility of a essential for defining the order?

If $ a $ and $ n $ share a common factor, then $ a^k $ remains divisible by that factor for every $ k $, and $ a^k \bmod n $ is never 1: the order does not exist. Conversely, the condition $ \gcd(a, n) = 1 $ guarantees that $ a $ has an inverse modulo $ n $, and Fermat's little theorem as well as Euler's theorem ensure that $ a^{\varphi(n)} \equiv 1 \pmod{n} $: the set of valid exponents is therefore never empty, and a minimum always exists.

Why does the order always divide Euler's totient?

This is a direct consequence of Lagrange's theorem: in a finite group, the order of an element divides the order of the group.

Now the group $ (\mathbb{Z}/n\mathbb{Z})^* $ has exactly $ \varphi(n) $ elements, where $ \varphi $ is Euler's totient function.

Thus $ \operatorname{ord}_n(a) $ divides $ \varphi(n) $.

Note: The order also divides the value $ \lambda(n) $ of the Carmichael function, which is the smallest universal exponent annihilating all elements of the group.

What does maximal order mean? What is a primitive root?

When $ \operatorname{ord}_n(a) = \varphi(n) $, the element $ a $ alone traverses the entire group of units: $ a $ is a primitive root (or generator) modulo $ n $, and the group is cyclic.

In other words, the powers of $ a $ generate all invertible elements, each exactly once per cycle.

What is the algorithm for computing the multiplicative order?

The algorithm can be summarized as:

function multiplicative_order(a, n)

if gcd(a, n) ≠ 1 → return "order undefined"

e ← φ(n) # via factorization of n

factor e = ∏ p_i^{e_i} # factorization of φ(n)

for each prime factor p of e →

while e mod p = 0 and a^(e/p) ≡ 1 (mod n) :

e ← e / p

return e

Or in Python code: def multiplicative_order(a, n):

if math.gcd(a, n) != 1:

return None

e = phi(n)

for p in prime_factors(e):

while e % p == 0 and pow(a, e // p, n) == 1:

e //= p

return e

What is the link between multiplicative order and discrete logarithm?

The discrete logarithm is the inverse problem of exponentiation: given $ g $ and $ g^x \bmod p $, find $ x $.

What are the uses of the multiplicative order in cryptography?

The multiplicative order is the safeguard of several protocols.

For RSA: if the encryption exponent shared a small order with certain messages, short cycles would appear and make the ciphertext predictable; security implicitly assumes large and poorly known orders.

For the Diffie-Hellman key exchange: security relies on a generator of large prime order, choosing a small-order subgroup would make it possible to steal secrets.

For ElGamal and DSA: same requirements, the order of the generator must be a large prime, often a prime divisor $ q $ of $ p - 1 $.

Overall, a golden rule: any element of small order is a cryptographic flaw.

Source code

dCode retains ownership of the "Multiplicative Order" source code. Any algorithm for the "Multiplicative Order" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Multiplicative Order" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Multiplicative Order" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.

Cite dCode

The content of the page "Multiplicative Order" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).

Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).

To cite dCode.fr on another website, use the link: https://www.dcode.fr/multiplicative-order

In a scientific article or book, the recommended bibliographic citation is: Multiplicative Order on dCode.fr [online website], retrieved on 2026-11-02, https://www.dcode.fr/multiplicative-order

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Multiplicative Order' tool for free! Thank you!


https://www.dcode.fr/multiplicative-order
© 2026 dCode — The ultimate collection of tools for games, math, and puzzles.
▲  
Feedback