Carmichael Function - Ymin Ge - X
Carmichael Function - Ymin Ge - X
Yimin Ge
Vienna, Austria
Abstract
The well known Euler’s Theorem states that xϕ(m) ≡ 1 (mod m) for every positive
integer m and every integer x coprime to m, where ϕ is the Euler’s Totient Function.
However, with some exceptions, ϕ(m) is usually not the least positive integer t so
that xt ≡ 1 (mod m) holds for all integers x with gcd(x, m) = 1 and can be ”optimized”
to the so-called Carmichael Function λ(m).
Properties of this function keep appearing in Olympiad problems and can often be
very useful. The purpose of this note is to state and prove some of these properties
and to give some examples of how they can be applied in Olympiad problems.
1 Introduction
The following problem was given at the 3rd round of the 2006 Iranian National Olympiad:
Problem 1. Let n be a positive integer and let d be the least positive integer, so that ad ≡ 1
(mod n) holds for every integer a with gcd(a, n) = 1. Prove that there exists an integer b so
that ordn (b) = d.
We will see that this problem is a special case of a more general result, but before proving
it, we shall cover some theory.
Definition 1. For a positive integer m and an integer x with gcd(x, m) = 1, the order of x
modulo m, denoted by ordm (x), is the least positive integer t, so that xt ≡ 1 (mod m).
Euler’s Theorem does not only imply that ordm (x) exists but implies ordm (x) ≤ ϕ(m).
Lemma 1. Let m be a positive integer and x be an integer coprime to m. Then xn ≡
1 (mod m) if and only if ordm (x) | n. Furthermore, xn1 ≡ xn2 (mod m) if and only if
ordm (x) | (n1 − n2 ).
Proof. Let d = ordm (x). It is clear that d | n implies xn ≡ 1 (mod m). On the other hand,
if xn ≡ 1 (mod m), there exist integers q, r such that n = qd + r and 0 ≤ r ≤ d − 1. Then
1
Definition 2. Let m be a positive integer. An integer g is called a primitive root modulo
m if ordm (g) = ϕ(m).
Primitive roots however do not exist for every positive integer m.
Lemma 2. Let m be a positive integer greater than 1. Then primitive roots modulo m exist
if and only if m has the form 2, 4, pk or 2pk where p is an odd prime number and k is a
positive integer.
This theorem is very well known, we skip the rather long proof of it (interested readers
can find a proof in [2]).
Hence, either
k−2 k−2
x2 ≡ 1 + 2k (mod 2k+2 ) or x2 ≡ 1 + 2k + 2k+1 (mod 2k+2 ).
2
In both cases, we have
k−1
x2 ≡ 1 + 2k+1 6≡ 1 (mod 2k+2 ).
Thus, ord2k+2 (x) > 2k−1 . On the other hand, ord2k+2 (x) | ϕ(2k+2 ) = 2k+1 by Lemma 1, so
ord2k+2 (x) ∈ {2k , 2k+1 }. But ord2k+2 (x) cannot exceed λ(2k+2 ) and we already know that
λ(2k+2 ) ≤ 2k . It follows that ord2k+2 (x) = 2k and thus λ(2k+2 ) = 2k .
The proof of Lemma 4 also shows that
Lemma 5. For any x congruent to 3 or 5 modulo 8, ord2k (x) = λ(2k ) = 2k−2 for all k ≥ 3.
Now, let a and b be two coprime positive integers and let d1 = λ(a), d2 = λ(b) and
d = λ(ab). Then xd ≡ 1 (mod ab) for any integer x coprime to ab, so
for all integers x coprime to ab. Now, from Lemma 3 it follows that d1 | d and d2 | d is a
necessary and sufficient condition for (1) and since d is the least positive integer satisfying
(1), it follows that d = lcm(d1 , d2 ). We thus obtain
Lemma 6. For any coprime positive integers a and b, λ(ab) = lcm(λ(a), λ(b)).
We see that Lemma 2, 4 and 6 already give a complete formula for λ(m). We summarize:
i=1
We can now return to the beginning of this note and solve Problem 1.
Lemma 7. For any positive integer m, there exists an integer x so that ordm (x) = λ(m).
Proof. Let m = pk11 · . . . · pkr r be the prime factorization of m and let x be a solution of the
congruence system
x ≡ gi (mod pki i ) for i = 1, . . . , r,
where gi are integers satisfying ordpki (x) = λ(pki i ) respectively (they exist by Lemma 2 and
i
5). Such an x exists by the Chinese Remainder Theorem.
Then by Lemma 1, λ(pki i ) = ordpki (x) | ordm (x) for all i = 1, . . . , r. It follows that
i
3
However, Lemma 7 can be generalized to
Theorem 2. Let m and d be positive integers. Then there exists an integer x with ordm (x) =
d if and only if d | λ(m).
Proof. If ordm (x) = d for some x, then Lemma 1 implies d | λ(m).
On the other hand, if d | λ(m), let z be an integer with ordm (z) = λ(m) (which exists by
Lemma 7), e = λ(m)/d, and x = z e . Then ordm (x) = d because
xd = z ed = z λ(m) ≡ 1 (mod m)
and ordm (x) < d would imply ordm (z) < ed = λ(m), a contradiction.
The application of the properties of the Carmichael Function are, when possible, not
always as obvious as it has been in Problem 1. The following problem illustrates another
kind of usage:
Problem 2. Prove that for any positive integer k, there is a positive integer n so that
2k | (3n + 5).
Solution. We will only discuss k ≥ 3. The statement is true for k = 3, just take n = 1 (we
need this for the purpose of induction).
It follows from Lemma 5 that ord2k (3) = λ(2k ) = 2k−2 , so by Lemma 1, the numbers
k−2
31 , 32 , . . . , 32 all give different residues modulo 2k . However, since
ord2k+1 (3) = λ(2k+1 ) = 2k−1 > 2k−2 = ord2k (3),
from Lemma 1 it follows that
k−2 k−2
3i+2 ≡ 3i (mod 2k ) and 3i+2 6≡ 3i (mod 2k+1 )
and thus
k−2
3i+2 ≡ 3i + 2k (mod 2k+1 ).
Hence, if 3i ≡ −5 (mod 2k ), then either
k−2
3i ≡ −5 (mod 2k+1 ) or 3i+2 ≡ −5 (mod 2k+1 ).
References
[1] Mathlinks, Order,
http://www.mathlinks.ro/Forum/viewtopic.php?t=108204
[2] Mathlinks, Primitive root,
http://www.mathlinks.ro/Forum/viewtopic.php?t=55473
[3] Mathlinks, (2k ) | (3m + 5),
http://www.mathlinks.ro/Forum/viewtopic.php?t=1912