Order of Two
Find \( \operatorname{ord}_7(2) \).
Compute powers of \(2\) until \(1\) first appears.
\(2^1\equiv2\), \(2^2\equiv4\), \(2^3\equiv8\equiv1\pmod7\). Since \(1\) did not appear earlier, the order is \(3\).
Chapter
Theory
The order of \(a\) modulo \(m\) is the length of the power cycle \(a,a^2,a^3,\ldots\) until \(1\) first appears. If \( \gcd(a,m)=1 \), order turns huge powers into small residues and gives restrictions on prime divisors.
If \(d=\operatorname{ord}_m(a)\), then \(a^k\equiv1\pmod m\) if and only if \(d\mid k\). For a prime \(p\), the order of every nonzero residue modulo \(p\) divides \(p-1\). If \(p\mid a^n-1\), then \( \operatorname{ord}_p(a)\mid n \). If \(p\mid a^n+1\), then the order divides \(2n\), but not \(n\).
Use order when a problem contains large powers, divisibility \(p\mid a^n\pm1\), last digits, residue cycles, or restrictions on possible prime divisors.
Expressions \(a^n\equiv1\), \(a^n\equiv-1\), \(p\mid a^n-1\), \(p\mid a^n+1\) almost always point to order. If the exponent is huge, first find the cycle length, then reduce the exponent modulo that length.
Order is defined only when \( \gcd(a,m)=1 \). Do not claim the order is \(p-1\) when you only know it divides \(p-1\). In problems with \(a^n+1\), one must separately prove that the order does not divide \(n\).
1. Are the base and modulus coprime? 2. What is the smallest exponent giving \(1\)? 3. Does the order divide the needed exponent? 4. If a prime \(p\) appears, what follows from \(d\mid p-1\)? 5. Has the case \(p=2\) been checked separately?
Examples
This shows the definition on a small modulus.
Problem. Find \( \operatorname{ord}_7(2) \).
Compute powers: \(2^1\equiv2\), \(2^2\equiv4\), \(2^3\equiv8\equiv1\pmod7\). The value \(1\) did not appear earlier, so the order is \(3\).
Comment. The order is the first exponent giving \(1\), not just any exponent.
This teaches reducing the exponent modulo the order.
Problem. Find the remainder of \(2^{100}\) modulo \(7\).
From the previous example, \(2^3\equiv1\pmod7\). Since \(100\equiv1\pmod3\), we get \(2^{100}\equiv2^1\equiv2\pmod7\).
Comment. Once the order is known, large powers become short.
This shows that the order divides \(p-1\).
Problem. Find \( \operatorname{ord}_{11}(3) \).
We have \(3^1\equiv3\), \(3^2\equiv9\), \(3^3\equiv27\equiv5\), \(3^4\equiv15\equiv4\), \(3^5\equiv12\equiv1\pmod{11}\). Thus the order is \(5\), and it indeed divides \(10\).
Comment. This illustrates the fact \(d\mid p-1\).
This shows how order restricts a prime divisor.
Problem. Let a prime \(p\mid 2^m-1\). Prove that \( \operatorname{ord}_p(2)\mid m \) and \( \operatorname{ord}_p(2)\mid p-1 \).
From \(p\mid2^m-1\), we get \(2^m\equiv1\pmod p\), so the order of \(2\) modulo \(p\) divides \(m\). Since \(p\) is prime and \(2\not\equiv0\pmod p\), the order also divides \(p-1\).
Comment. This often gives restrictions on \(p\).
This teaches not forgetting the condition 'does not divide \(n\)'.
Problem. Let \(p\) be an odd prime divisor of \(a^n+1\), with \(p\nmid a\). What can be said about the order of \(a\) modulo \(p\)?
We have \(a^n\equiv-1\pmod p\). Then \(a^{2n}\equiv1\), so the order divides \(2n\). But the order does not divide \(n\), otherwise \(a^n\equiv1\), contradicting \(a^n\equiv-1\) for odd \(p\).
Comment. This is one of the main templates for problems on \(a^n+1\).
This prepares for strong problems.
Problem. Let a prime \(q\mid 2^{16}+1\). Prove that \(q\equiv1\pmod{32}\).
If \(q=2\), then \(2^{16}+1\) is odd, so \(q\ne2\). From \(2^{16}\equiv-1\pmod q\), we get \(2^{32}\equiv1\), but \(2^{16}\not\equiv1\). The order of \(2\) modulo \(q\) is \(32\), hence \(32\mid q-1\).
Comment. The exponent \(16=2^4\) forces the order to be exactly \(32\).
This shows how Fermat shortens a problem.
Problem. Find all primes \(p\) such that \(p\mid2^p+1\).
For \(p=2\), \(2^2+1=5\), not divisible by \(2\). For odd \(p\), Fermat's little theorem gives \(2^p\equiv2\pmod p\). Then the condition gives \(2^p+1\equiv3\equiv0\pmod p\), so \(p=3\). Check: \(2^3+1=9\) is divisible by \(3\).
Comment. Order is not strictly necessary here, but the cycle idea is the same.
An olympiad example using order and the sign \(-1\).
Problem. Prove that the numbers \(F_n=2^{2^n}+1\) are pairwise coprime.
Let \(m
Comment. The same residue cannot be both \(1\) and \(-1\) modulo an odd number.
Problems
Find \( \operatorname{ord}_7(2) \).
Compute powers of \(2\) until \(1\) first appears.
\(2^1\equiv2\), \(2^2\equiv4\), \(2^3\equiv8\equiv1\pmod7\). Since \(1\) did not appear earlier, the order is \(3\).
Find \( \operatorname{ord}_{11}(3) \).
The powers must first reach \(1\).
\(3,9,27,81,243\) modulo \(11\) give \(3,9,5,4,1\). Therefore \( \operatorname{ord}_{11}(3)=5 \).
Find the remainder of \(2^{100}\) modulo \(7\).
Use \(2^3\equiv1\pmod7\).
Since the order of \(2\) modulo \(7\) is \(3\), reduce the exponent: \(100\equiv1\pmod3\). Hence \(2^{100}\equiv2\pmod7\).
Find the last digit of \(3^{2026}\).
Work modulo \(10\); the powers of \(3\) have cycle length \(4\).
Powers of \(3\) modulo \(10\) are \(3,9,7,1\), then the cycle repeats. Since \(2026\equiv2\pmod4\), the last digit is \(9\).
Find \( \operatorname{ord}_{13}(5) \).
Notice that \(5^2\equiv-1\pmod{13}\).
\(5^2=25\equiv12\equiv-1\pmod{13}\). Hence \(5^4\equiv1\). The order is not \(1\) or \(2\), because \(5\not\equiv1\) and \(5^2\not\equiv1\). Therefore the order is \(4\).
Let \( \gcd(a,m)=1 \) and \(d=\operatorname{ord}_m(a)\). Prove that \(a^k\equiv1\pmod m\) if and only if \(d\mid k\).
Divide \(k\) by \(d\) with remainder.
Let \(k=qd+r\), where \(0\le r
Let \( \gcd(a,m)=1 \), \(a^r\equiv1\pmod m\), and \(a^s\equiv1\pmod m\). Prove that \(a^{\gcd(r,s)}\equiv1\pmod m\).
Let \(d=\operatorname{ord}_m(a)\).
If \(d=\operatorname{ord}_m(a)\), then \(a^r\equiv1\) and \(a^s\equiv1\) imply \(d\mid r\) and \(d\mid s\). Therefore \(d\mid\gcd(r,s)\), hence \(a^{\gcd(r,s)}\equiv1\pmod m\).
Let an odd prime \(p\mid2^m-1\). Prove that \( \operatorname{ord}_p(2)\mid \gcd(m,p-1) \).
The order divides both the exponent and \(p-1\).
From \(2^m\equiv1\pmod p\), we get \( \operatorname{ord}_p(2)\mid m \). Since \(p\) is prime and \(2\not\equiv0\pmod p\), the order also divides \(p-1\). Therefore it divides \(\gcd(m,p-1)\).
Find all primes \(p\) such that \(p\mid2^p+1\).
For odd \(p\), use \(2^p\equiv2\pmod p\).
For \(p=2\), there is no divisibility. If \(p\) is odd, Fermat's little theorem gives \(2^p\equiv2\pmod p\). Then \(2^p+1\equiv3\pmod p\), so \(p\mid3\), hence \(p=3\). Check: \(2^3+1=9\) is divisible by \(3\).
Let \(p\) be prime, \(p\nmid a\), and \(p\mid a^2+a+1\). Prove that \(p=3\) or \(p\equiv1\pmod3\).
Multiply \(a^2+a+1\) by \(a-1\).
From \(a^2+a+1\equiv0\pmod p\), we get \(a^3-1=(a-1)(a^2+a+1)\equiv0\pmod p\). If \(a\equiv1\pmod p\), then \(3\equiv0\pmod p\), so \(p=3\). If \(a\not\equiv1\), the order of \(a\) is \(3\), hence \(3\mid p-1\), so \(p\equiv1\pmod3\).
Find the last two digits of \(7^{100}\).
Check a short cycle modulo \(100\).
Compute \(7^2=49\), \(7^4\equiv49^2=2401\equiv1\pmod{100}\). Since \(100\) is divisible by \(4\), \(7^{100}=(7^4)^{25}\equiv1\pmod{100}\). The last two digits are \(01\).
Find all positive integers \(n\) such that \(5^n\equiv1\pmod{31}\).
Find the order of \(5\) modulo \(31\).
We have \(5^2=25\not\equiv1\pmod{31}\), while \(5^3=125\equiv1\pmod{31}\). Hence \( \operatorname{ord}_{31}(5)=3 \). Therefore \(5^n\equiv1\pmod{31}\) if and only if \(3\mid n\).
Find all positive integers \(n\) such that \(2^n\equiv-1\pmod{17}\).
Notice that \(2^4\equiv-1\pmod{17}\).
Compute \(2^4=16\equiv-1\pmod{17}\), hence \(2^8\equiv1\). The order of \(2\) modulo \(17\) is \(8\), because the smaller divisors \(1,2,4\) do not give \(1\). Thus \(2^n\equiv-1\) exactly when \(n\equiv4\pmod8\).
Let \(p\) be an odd prime, \(p\nmid a\), and \(p\mid a^n+1\). Prove that \( \operatorname{ord}_p(a) \) divides \(2n\), but does not divide \(n\).
Translate the condition into \(a^n\equiv-1\pmod p\).
From \(p\mid a^n+1\), we get \(a^n\equiv-1\pmod p\). Then \(a^{2n}\equiv1\), so the order divides \(2n\). If the order divided \(n\), then \(a^n\equiv1\pmod p\), contradicting \(a^n\equiv-1\pmod p\), since \(p\) is odd.
Let a prime \(q\mid2^{16}+1\). Prove that \(q\equiv1\pmod{32}\).
Show that the order of \(2\) modulo \(q\) is \(32\).
The number \(2^{16}+1\) is odd, so \(q\ne2\). From \(2^{16}\equiv-1\pmod q\), we get \(2^{32}\equiv1\). Also \(2^{16}\not\equiv1\), and the order divides \(32\). The only divisor of \(32\) that does not divide \(16\) is \(32\). Thus the order of \(2\) modulo \(q\) is \(32\). Therefore \(32\mid q-1\), so \(q\equiv1\pmod{32}\).
Find all primes \(p\) such that \(p\mid3^4+1\).
First compute the number, then explain the restriction by order.
\(3^4+1=82=2\cdot41\). Hence \(p=2\) or \(p=41\). For the method: if \(p\ne2\) divides \(3^4+1\), then \(3^4\equiv-1\), so the order of \(3\) modulo \(p\) is \(8\), and \(8\mid p-1\). Among the divisors of \(82\), this holds only for \(41\).
Let \(r\ge0\), let \(p\) be an odd prime, \(p\nmid a\), and \(p\mid a^{2^r}+1\). Prove that \(p\equiv1\pmod{2^{r+1}}\).
The order divides \(2^{r+1}\), but not \(2^r\).
From the condition \(a^{2^r}\equiv-1\pmod p\). Then \(a^{2^{r+1}}\equiv1\), so the order of \(a\) modulo \(p\) divides \(2^{r+1}\). But the order does not divide \(2^r\), otherwise \(a^{2^r}\equiv1\), not \(-1\). Among the divisors of \(2^{r+1}\), the only one not dividing \(2^r\) is \(2^{r+1}\). Hence the order is \(2^{r+1}\), and it divides \(p-1\).
Prove that the numbers \(F_n=2^{2^n}+1\) are pairwise coprime.
Let one prime divide \(F_m\) and \(F_n\), where \(m
Let \(q\) be a common prime divisor of \(F_m\) and \(F_n\), \(m
Let \(k\) be a fixed positive integer. Prove that there are infinitely many primes \(q\equiv1\pmod{2^k}\).
Use prime divisors of \(2^{2^n}+1\) for \(n\ge k-1\).
Take \(F_n=2^{2^n}+1\) for \(n\ge k-1\). Every prime divisor \(q\) of \(F_n\) is odd and, by the Fermat-type lemma, satisfies \(q\equiv1\pmod{2^{n+1}}\), hence also \(q\equiv1\pmod{2^k}\). The numbers \(F_n\) are pairwise coprime, so their prime divisors for different \(n\) do not repeat. Therefore infinitely many such primes exist.
Let \(p\) be an odd prime, \(p\nmid a\), and \(p\mid a^6-1\), but \(p\nmid a^3-1\) and \(p\nmid a^2-1\). Prove that \(p\equiv1\pmod6\).
Determine the order of \(a\) modulo \(p\).
Let \(d=\operatorname{ord}_p(a)\). From \(a^6\equiv1\pmod p\), we get \(d\mid6\). The conditions \(p\nmid a^3-1\) and \(p\nmid a^2-1\) mean \(d\nmid3\) and \(d\nmid2\). Among the divisors of \(6\), only \(6\) divides neither \(2\) nor \(3\). Hence \(d=6\). The order modulo a prime divides \(p-1\), so \(6\mid p-1\), meaning \(p\equiv1\pmod6\).
Ladders