콘텐츠로 이동

20. Fermat's and Euler's Theorems

Fermat's Theorem

Concept 20.1 : Ring structure on \(\mathbb{Z} / n \mathbb{Z}\)

As additive groups, \(\mathbb{Z}_{n}\) and \(\mathbb{Z} / n \mathbb{Z}\) are naturally isomorphic by matching the coset \(a+n \mathbb{Z}\) with the element \(a\) of \(\mathbb{Z}_{n}\). Addition in \(\mathbb{Z} / n \mathbb{Z}\) is computed by choosing representatives of the two cosets, adding those representatives in \(\mathbb{Z}\), and then taking the coset of \(n \mathbb{Z}\) that contains the sum. Multiplication of cosets is defined in the same representative-based way: choose representatives, multiply them in \(\mathbb{Z}\), and take the coset of \(n \mathbb{Z}\) containing the product. The only point that must be checked is that this multiplication does not depend on the chosen representatives. Suppose that \(a+r n\) and \(b+s n\) are chosen instead of \(a\) and \(b\) from the cosets \(a+n \mathbb{Z}\) and \(b+n \mathbb{Z}\). Then

\[ (a+r n)(b+s n)=a b+(a s+r b+r s n) n, \]

which is still an element of \(a b+n \mathbb{Z}\). Thus the product coset is independent of the representatives chosen. Associativity of multiplication and the distributive laws then follow from the corresponding properties in \(\mathbb{Z}\).

Therefore \(\mathbb{Z} / n \mathbb{Z}\) forms a ring, and this ring is isomorphic to \(\mathbb{Z}_{n}\).

Theorem 20.2 : Nonzero elements under field multiplication

For any field, the nonzero elements form a group under the field multiplication.

Proof

Let \(F\) be a field and let \(F^{\times}=F\setminus\{0\}\). If \(a,b\in F^{\times}\) and \(ab=0\), multiplying by \(a^{-1}\) gives \(b=a^{-1}(ab)=a^{-1}0=0\), a contradiction. Thus \(F^{\times}\) is closed under multiplication. Multiplication is associative on \(F^{\times}\) because it is associative on \(F\). The multiplicative identity \(1\) belongs to \(F^{\times}\) since \(1\ne 0\). Every \(a\in F^{\times}\) has a multiplicative inverse \(a^{-1}\in F\), and \(a^{-1}\ne 0\) because \(aa^{-1}=1\ne 0\). Hence \(F^{\times}\) forms a group under field multiplication.

Theorem 20.3 : Little theorem of Fermat

If \(a \in \mathbb{Z}\) and \(p\) is a prime not dividing \(a\), then \(p\) divides \(a^{p-1}-1\). Equivalently, \(a^{p-1} \equiv 1(\bmod p)\) for \(a \neq 0(\bmod p)\).

Proof

In \(\mathbb{Z}_{p}\), the elements

\[ 1,2,3, \cdots, p-1 \]

form a group of order \(p-1\) under multiplication modulo \(p\) by Theorem 20.2. According to Corollary 10.9, the order of any element in a group divides the order of the group. Hence, for \(b \neq 0\) and \(b \in \mathbb{Z}_{p}\), we have \(b^{p-1}=1\) in \(\mathbb{Z}_{p}\). Since \(\mathbb{Z}_{p}\) is isomorphic to the ring of cosets of the form \(a+p \mathbb{Z}\), it follows that for any \(a \in \mathbb{Z}\) not in the coset \(0+p \mathbb{Z}\), we have

\[ a^{p-1} \equiv 1(\bmod p). \]

Corollary 20.4 : Fermat congruence for integers

If \(a \in \mathbb{Z}\) and \(p\) is prime, then \(a^{p} \equiv a(\bmod p)\).

Proof

If \(a \not \equiv 0(\bmod p)\), the result follows from Theorem 20.3. If \(a \equiv 0(\bmod p)\), then both sides reduce to \(0\) modulo \(p\).

Euler's Generalization

Theorem 20.5 : Nonzero non-divisors of \(0\) in \(\mathbb{Z}_{n}\)

Let \(G_{n}\) be the set of nonzero elements of \(\mathbb{Z}_{n}\) that are not \(0\) divisors. Then \(G_{n}\) forms a group under multiplication modulo \(n\).

Proof

First we show that \(G_{n}\) is closed under multiplication modulo \(n\). Let \(a,b \in G_{n}\). Suppose, for contradiction, that \(a b \notin G_{n}\). Then there would be some \(c \neq 0\) in \(\mathbb{Z}_{n}\) such that \((a b)c=0\). Since \((a b)c=0\) implies \(a(b c)=0\), and since \(b \in G_{n}\) with \(c \neq 0\), we have \(b c \neq 0\). But then \(a(b c)=0\) would say that \(a\) is a divisor of \(0\), contradicting \(a \in G_{n}\). Hence \(G_{n}\) is closed under multiplication modulo \(n\). The same argument shows that, in any ring, the elements that are not divisors of \(0\) are closed under multiplication. Up to this point, no special structure of \(\mathbb{Z}_{n}\) beyond its ring structure has been used.

We now prove that \(G_{n}\) is a group. Multiplication modulo \(n\) is associative, and \(1 \in G_{n}\). It remains to show that each \(a \in G_{n}\) has a multiplicative inverse in \(G_{n}\). List the elements of \(G_{n}\) as

\[ 1, a_{1}, \cdots, a_{r}. \]

For fixed \(a \in G_{n}\), consider

\[ a 1, a a_{1}, \cdots, a a_{r}. \]

These elements are all different. Indeed, if \(a a_{i}=a a_{j}\), then \(a\left(a_{i}-a_{j}\right)=0\). Since \(a\) is not a divisor of \(0\), we must have \(a_{i}-a_{j}=0\), so \(a_{i}=a_{j}\). By closure, the displayed products all lie in \(G_{n}\), and by the preceding paragraph they are all distinct. Therefore, by counting the elements of \(G_{n}\), one of them must be \(1\). Thus either \(a 1=1\) or \(a a_{i}=1\) for some \(i\), so \(a\) has a multiplicative inverse. Hence \(G_{n}\) is a group under multiplication modulo \(n\).

Definition 20.6 : Euler phi-function

Let \(n\) be a positive integer. Define \(\varphi(n)\) to be the number of positive integers less than or equal to \(n\) and relatively prime to \(n\). In particular, \(\varphi(1)=1\).

By Theorem 19.2, \(\varphi(n)\) is also the number of nonzero elements of \(\mathbb{Z}_{n}\) that are not divisors of \(0\). The function \(\varphi: \mathbb{Z}^{+} \rightarrow \mathbb{Z}^{+}\) is the Euler phi-function.

Theorem 20.7 : Euler's theorem

If \(a\) is an integer relatively prime to \(n\), then \(a^{\varphi(n)}-1\) is divisible by \(n\). Equivalently,

\[ a^{\varphi(n)} \equiv 1(\bmod n). \]

Proof

Since \(a\) is relatively prime to \(n\), the coset \(a+n \mathbb{Z}\) of \(n \mathbb{Z}\) containing \(a\) contains an integer \(b<n\) that is relatively prime to \(n\). Multiplication of these cosets is well defined by multiplying representatives modulo \(n\), so

\[ a^{\varphi(n)} \equiv b^{\varphi(n)}(\bmod n). \]

By Theorem 19.2 and Theorem 20.5, the integer \(b\) can be viewed as an element of the multiplicative group \(G_{n}\) of order \(\varphi(n)\) consisting of the \(\varphi(n)\) elements of \(\mathbb{Z}_{n}\) relatively prime to \(n\). Thus

\[ b^{\varphi(n)} \equiv 1(\bmod n), \]

and therefore

\[ a^{\varphi(n)} \equiv 1(\bmod n). \]

Application to \(a x \equiv b(\bmod m)\)

Theorem 20.8 : Solving \(a x=b\) in \(\mathbb{Z}_{m}\) with relatively prime coefficient

Let \(m\) be a positive integer and let \(a \in \mathbb{Z}_{m}\) be relatively prime to \(m\). For each \(b \in \mathbb{Z}_{m}\), the equation \(a x=b\) has a unique solution in \(\mathbb{Z}_{m}\).

Proof

By Theorem 20.5, \(a\) is a unit in \(\mathbb{Z}_{m}\), and \(s=a^{-1} b\) is certainly a solution of the equation. Multiplying both sides of \(a x=b\) on the left by \(a^{-1}\) shows that this is the only solution.

Corollary 20.9 : Solving \(a x \equiv b(\bmod m)\) with relatively prime coefficient

If \(a\) and \(m\) are relatively prime integers, then for any integer \(b\), the congruence \(a x \equiv b(\bmod m)\) has as solutions all integers in precisely one residue class modulo \(m\).

Theorem 20.10 : Solving \(a x=b\) in \(\mathbb{Z}_{m}\)

Let \(m\) be a positive integer and let \(a, b \in \mathbb{Z}_{m}\). Let \(d\) be the gcd of \(a\) and \(m\). The equation \(a x=b\) has a solution in \(\mathbb{Z}_{m}\) if and only if \(d\) divides \(b\). When \(d\) divides \(b\), the equation has exactly \(d\) solutions in \(\mathbb{Z}_{m}\).

Proof

First suppose that \(a x=b\) has a solution in \(\mathbb{Z}_{m}\). Let \(s \in \mathbb{Z}_{m}\) be such a solution. Then \(a s-b=q m\) in \(\mathbb{Z}\) for some integer \(q\), so \(b=a s-q m\). Since \(d\) divides both \(a\) and \(m\), it divides the right-hand side of \(b=a s-q m\). Hence \(d\) divides \(b\). Thus a solution can exist only if \(d\) divides \(b\).

Conversely, suppose that \(d\) divides \(b\). Write

\[ a=a_{1} d, \quad b=b_{1} d, \quad \text { and } \quad m=m_{1} d \text {. } \]

Then the equation \(a s-b=q m\) in \(\mathbb{Z}\) can be rewritten as \(d\left(a_{1} s-b_{1}\right)=d q m_{1}\). Therefore \(a s-b\) is a multiple of \(m\) if and only if \(a_{1} s-b_{1}\) is a multiple of \(m_{1}\). Thus the solutions \(s\) of \(a x=b\) in \(\mathbb{Z}_{m}\) are precisely the elements that, read modulo \(m_{1}\), yield solutions of \(a_{1} x=b_{1}\) in \(\mathbb{Z}_{m_{1}}\). Let \(s \in \mathbb{Z}_{m_{1}}\) be the unique solution of \(a_{1} x=b_{1}\) in \(\mathbb{Z}_{m_{1}}\) given by Theorem 20.8. The elements of \(\mathbb{Z}_{m}\) that reduce to \(s\) modulo \(m_{1}\) are precisely

\[ s, s+m_{1}, s+2 m_{1}, s+3 m_{1}, \cdots, s+(d-1) m_{1}. \]

Hence there are exactly \(d\) solutions of the equation in \(\mathbb{Z}_{m}\).

Corollary 20.11 : Solving \(a x \equiv b(\bmod m)\)

Let \(d\) be the gcd of positive integers \(a\) and \(m\). The congruence \(a x \equiv b(\bmod m)\) has a solution if and only if \(d\) divides \(b\). When this condition holds, the solutions are the integers in exactly \(d\) distinct residue classes modulo \(m\).

Example 20.12 : Solving \(15 x \equiv 27(\bmod 18)\)

Find all solutions of the congruence \(15 x \equiv 27(\bmod 18)\). The gcd of \(15\) and \(18\) is \(3\), and \(3\) does divide \(27\). Divide everything by \(3\) and consider the congruence \(5 x \equiv 9(\bmod 6)\), which amounts to solving the equation \(5 x=3\) in \(\mathbb{Z}_{6}\). The units in \(\mathbb{Z}_{6}\) are \(1\) and \(5\), and \(5\) is its own inverse in this group of units. Thus the solution in \(\mathbb{Z}_{6}\) is \(x=\left(5^{-1}\right)(3)=(5)(3)=3\). Consequently, the solutions of \(15 x \equiv 27(\bmod 18)\) are the integers in the following three residue classes.

\[ \begin{aligned} 3+18 \mathbb{Z} & =\{\cdots,-33,-15,3,21,39, \cdots\} \\ 9+18 \mathbb{Z} & =\{\cdots,-27,-9,9,27,45, \cdots\} \\ 15+18 \mathbb{Z} & =\{\cdots,-21,-3,15,33,51, \cdots\} \end{aligned} \]

This illustrates Corollary 20.11. Note the \(d=3\) solutions \(3,9\), and \(15\) in \(\mathbb{Z}_{18}\). All the solutions in the three displayed residue classes modulo \(18\) can be collected in the one residue class \(3+6 \mathbb{Z}\) modulo \(6\), since they came from the solution \(x=3\) of \(5 x=3\) in \(\mathbb{Z}_{6}\).