Module 3.3 · Number Theory
Orders and primitive roots
Euler's theorem says , but powers of often return to much sooner. The order of is the exact length of that cycle. Orders explain how long repeating decimals are, which primes can divide numbers like or , and how many solutions has. They drive many of the hardest AIME number theory problems.
Order
Definition
Order
If , the order of modulo , written , is the smallest positive integer with .
For example, mod the powers of are , so . The powers of are , so .
The order divides every exponent that gives 1
Let . Then
In particular , and for a prime , .
Proof. If , then . Conversely, suppose . Divide: with . Then . Since and is the smallest positive exponent giving , must be . So . Euler's theorem gives , so .
How to compute an order. The order divides , so only divisors need checking. Better: exactly when but for every prime . For , you only check and .
Primitive roots
Definition
Primitive root
is a primitive root mod if . Then the powers run through every residue coprime to .
Primitive roots mod a prime
Every prime has a primitive root . So every nonzero residue mod is for exactly one , and
Consequences:
- For each there are exactly residues of order . In particular there are primitive roots.
- has exactly solutions.
Why the formula holds. iff iff . The smallest such is . The counting facts follow: has order exactly when , which happens for values of ; and iff , which holds for values of .
The existence of a primitive root is a deeper fact (it uses that a polynomial of degree has at most roots mod ); on the AIME you can quote it. Primitive roots also exist mod and for odd primes , and mod and , but not mod or mod .
Three classic applications
Repeating decimals. If , the decimal for repeats with period exactly , because for an integer exactly when .
Prime factors of . Let be prime and suppose a prime divides . Then divides and isn't , so it equals . Since the order divides , you get . For , every prime factor is (it's odd too). The first candidate, , works: .
Prime factors of . If an odd prime divides , then and , so the order is exactly . Hence .
Orders mod prime powers
If exactly (with odd and ), then exactly. (Write and expand ; this is a case of lifting the exponent.) So once you know the order mod , each extra power of in the modulus multiplies the order by at most .
Worked example: Computing an order
Find .
The order divides . The maximal proper divisors are and . and . Neither is , so the order is : is a primitive root mod .
Worked example: A repeating decimal
How long is the repeating block of ?
, , . So , and indeed .
Worked example: Factoring with orders
Find the smallest prime factor of .
Any odd prime factor has , so and . And since is odd. The primes are Testing: , , , and . The answer is (and too, as it must be).
Worked example: Counting solutions
How many satisfy ?
With a primitive root , write . Then iff iff . There are such in , matching .
Common mistake
"" tells you the order divides , not that it equals . To prove the order is exactly , you must rule out every for primes .
Practice
Find the smallest positive integer such that is divisible by .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many integers with are primitive roots modulo ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many integers with satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many positive integers make divisible by ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the smallest positive integer such that .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the smallest prime such that the decimal expansion of repeats with period exactly .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the smallest prime factor of .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the smallest positive integer such that .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2019 AIME I, Problem 14: the least odd prime factor of ; the order argument forces .
- 2020 AIME I, Problem 12: the least making divisible by a product of prime powers; the mod- part is an order computation.