Skip to main content

OrderDem

Order Calculation Algorithm

Calculate the multiplicative order of aa modulo nn step by step

Understanding Multiplicative Order

The multiplicative order of an element aa modulo nn is the smallest positive integer kk such that ak1(modn)a^k \equiv 1 \pmod{n}. This algorithm efficiently computes this value:
  1. 1First, we verify that gcd(a,n)=1\gcd(a, n) = 1 to ensure aa is invertible modulo nn
  2. 2We start with an upper bound (either provided or computed using Carmichael's function)
  3. 3We factor this upper bound and systematically test if we can reduce it
  4. 4For each prime factor pp, we test if abound/p1(modn)a^{\mathrm{bound} / p} \equiv 1 \pmod{n}. If so, we replace bound\mathrm{bound} with bound/p\mathrm{bound} / p.
  5. 5We repeat this process until no further reduction is possible