MATH2400 2,423 words·13 min read

Modular Rings and Units

The Ring of Integers Modulo n#

Recall the number system

Zn={0,1,2,…,n−1},\mathbb{Z}_n = \{0,1,2,\dots,n-1\},

which has the same addition and multiplication as Z\mathbb{Z}, except that every result is always reduced to its smallest non-negative remainder modulo nn. For instance, in Z4\mathbb{Z}_4 we have 3+2=13+2=1, since 55 leaves a remainder of 11 when divided by 44.

Each element a∈Zna \in \mathbb{Z}_n is really a representative of a residue class; the set of all integers leaving the same remainder as aa when divided by nn,

[a]n={a+kn:k∈Z}.[a]_n = \{a + kn : k \in \mathbb{Z}\}.

In Z4\mathbb{Z}_4 for example, the element 11 stands for the class {…,−7,−3,1,5,9,… }\{\dots,-7,-3,1,5,9,\dots\}. Basically, Zn\mathbb{Z}_n chops the integers up into nn classes and does arithmetic on the classes themselves; we just use the smallest non-negative member of each class as its name.

Note

Fact
Zn\mathbb{Z}_n is a (commutative unital) ring for any positive integer nn.

So Zn\mathbb{Z}_n is our first example of a finite ring. Recall that a commutative unital ring is a set closed under two operations ++ and ×\times, where both operations are associative and commutative, there is an additive identity 00 and a multiplicative identity 11, every element has an additive inverse, and multiplication distributes over addition.

Example. Show that Z4\mathbb{Z}_4 is a ring.
We can draw up the full addition and multiplication tables for Z4\mathbb{Z}_4;

++ 00 11 22 33
00 00 11 22 33
11 11 22 33 00
22 22 33 00 11
33 33 00 11 22
×\times 00 11 22 33
00 00 00 00 00
11 00 11 22 33
22 00 22 00 22
33 00 33 22 11

From the tables we can read off most of the ring laws directly:

  • Every entry in both tables lies in {0,1,2,3}\{0,1,2,3\}, so Z4\mathbb{Z}_4 is closed under both operations.
  • The 00 row of the addition table and the 11 row of the multiplication table copy the headers, so 00 and 11 are the additive and multiplicative identities.
  • The element 00 appears in every row of the addition table, so every element has an additive inverse; −0=0-0 = 0, −1=3-1 = 3, −2=2-2 = 2 and −3=1-3 = 1.
  • Both tables are symmetric about the main diagonal, so both operations are commutative.

Associativity and distributivity hold because they already hold in Z\mathbb{Z}, and reducing modulo 44 at each step does not change which residue class an answer lands in. Therefore, Z4\mathbb{Z}_4 satisfies all of the ring axioms and is a ring. The same argument works for any nn, which is exactly the Fact above.

A First Look at Modular Fields#

Recall that a field is a commutative ring in which every nonzero element has a multiplicative inverse; you can divide by anything except 00.

Notice that Z4\mathbb{Z}_4 cannot be a field, since the nonzero element 22 does not have a multiplicative inverse. This is clear from the multiplication table above; 11 does not appear anywhere in 22's row, so no element multiplies with 22 to give 11.

Alternatively, we can argue it directly: if there were some a∈Z4a \in \mathbb{Z}_4 with 2a=12a = 1 in Z4\mathbb{Z}_4, then we would need 4∣(2a−1)4 \mid (2a - 1); but 2a−12a-1 is odd for every integer aa, so 44 can never divide it.

On the other hand, consider the multiplication table for Z3\mathbb{Z}_3;

×\times 00 11 22
00 00 00 00
11 00 11 22
22 00 22 11

Here every nonzero element does have a multiplicative inverse (1−1=11^{-1} = 1 and 2−1=22^{-1} = 2, since 2×2=4=12 \times 2 = 4 = 1 in Z3\mathbb{Z}_3), so Z3\mathbb{Z}_3 is a field.

A natural question to ask is: for which nn is Zn\mathbb{Z}_n a field? To answer this, we first need some language for the elements that do have inverses.

Units and Unit Groups#

Note

Definition
An element aa of a ring RR is called a unit (or invertible) if it has a multiplicative inverse in RR; that is, if there exists some b∈Rb \in R with ab=1ab = 1.

Basically, the units are the elements you are allowed to divide by. In Z4\mathbb{Z}_4 we just saw that 22 is not a unit while 33 is (since 3×3=9=13 \times 3 = 9 = 1 in Z4\mathbb{Z}_4); a field is then simply a commutative ring where every nonzero element is a unit.

Note

Definition
The unit group of a ring RR is the set of all units in RR, and is denoted by R∗R^*.

Example. Find the following unit groups.

  • Q∗=Q∖{0}\mathbb{Q}^* = \mathbb{Q} \setminus \{0\}; every nonzero fraction pq\frac{p}{q} has the inverse qp\frac{q}{p}, but nothing multiplies with 00 to give 11.
  • N∗={1}\mathbb{N}^* = \{1\}; for any n≥2n \geq 2 we would need nb=1nb=1 with b∈Nb \in \mathbb{N}, which is impossible since nbnb is either 00 or at least nn.
  • Z∗={−1,1}\mathbb{Z}^* = \{-1,1\}, since 1×1=11 \times 1 = 1 and (−1)×(−1)=1(-1)\times(-1) = 1, but no other integer has an integer inverse.
  • Z3∗={1,2}\mathbb{Z}_3^* = \{1,2\}, since 1×1=11 \times 1 = 1 and 2×2=4=12\times 2 = 4 = 1 in Z3\mathbb{Z}_3.
  • Z4∗={1,3}\mathbb{Z}_4^* = \{1,3\}, since 1×1=11 \times 1 = 1 and 3×3=9=13\times 3 = 9 = 1 in Z4\mathbb{Z}_4, while 00 and 22 have no inverse.

Notice how the unit group depends heavily on the ring; 12\frac{1}{2} rescues 22 in Q\mathbb{Q}, but in Z\mathbb{Z} or Z4\mathbb{Z}_4 there is no such element available.

Properties of Units#

Note

Fact
If RR is a ring and a∈Ra \in R is a unit, then a−1∈Ra^{-1} \in R is unique.
Proof. Suppose bb and cc are both inverses of aa, so ab=1ab = 1 and ac=1ac = 1. Then

b=b×1=b(ac), (as ac=1)=(ba)c, (associativity)=1×c, (as ba=1)=c.■\begin{align*} b &= b \times 1 \\ &= b(ac), \text{ (as } ac=1\text{)} \\ &= (ba)c, \text{ (associativity)} \\ &= 1 \times c, \text{ (as } ba=1\text{)} \\ &= c. \qquad \blacksquare \end{align*}

This is why we can safely write a−1a^{-1} for the inverse of aa; there is never more than one candidate.

Note

Fact
If RR is a ring and a,b∈R∗a,b \in R^*, then ab∈R∗ab \in R^*; in fact (ab)−1=b−1a−1(ab)^{-1} = b^{-1}a^{-1}.
Proof. Since aa and bb are units, a−1a^{-1} and b−1b^{-1} exist in RR, and

(ab)(b−1a−1)=a(bb−1)a−1, (associativity)=a×1×a−1=aa−1=1.■\begin{align*} (ab)(b^{-1}a^{-1}) &= a(bb^{-1})a^{-1}, \text{ (associativity)} \\ &= a \times 1 \times a^{-1} \\ &= aa^{-1} \\ &= 1. \qquad \blacksquare \end{align*}

So the units are closed under multiplication. This is exactly why R∗R^* is called the unit group: a group is a set with one operation satisfying the closure, associativity, identity and inverse laws, and R∗R^* under multiplication has all four. Closure is the Fact we just proved; associativity is inherited from RR; the identity is 11 (which is a unit since 1×1=11 \times 1 = 1); and if aa is a unit then so is a−1a^{-1}, because its inverse is just aa again. The remaining details are inherited straight from the ring so I'm not gonna belabour them.

Example. In Z10\mathbb{Z}_{10}, both 33 and 77 are units. Their product 3×7=21=13 \times 7 = 21 = 1 in Z10\mathbb{Z}_{10}, which is certainly a unit; and indeed (3×7)−1=1−1=1=7−1×3−1=3×7(3 \times 7)^{-1} = 1^{-1} = 1 = 7^{-1} \times 3^{-1} = 3 \times 7 reduced mod 1010. Closure holds exactly as promised.

Zero Divisors#

So units are the "good" elements. The next Fact tells us that, in a finite ring, the non-units are bad in a very specific way.

Note

Fact
If RR is a finite ring and a∈Ra \in R is not a unit, then a=0a = 0 or ab=0ab = 0 for some nonzero b∈Rb \in R.
Proof. Suppose a≠0a \neq 0 and aa is not a unit; we must produce a nonzero bb with ab=0ab=0.
Consider multiplying aa by every single element of RR. Since RR is finite, if all of these products were distinct then they would account for every element of RR; in particular, ab=1ab = 1 for some bb, which would make aa a unit. But aa is not a unit, so the products cannot all be distinct. Hence two of them coincide,

ab1=ab2,b1≠b2,a(b1−b2)=0,\begin{align*} ab_1 &= ab_2, \quad b_1 \neq b_2, \\ a(b_1 - b_2) &= 0, \end{align*}

and taking b=b1−b2≠0b = b_1 - b_2 \neq 0 gives ab=0ab = 0. ■\blacksquare

Note

Definition
A nonzero element aa of a ring RR is called a zero divisor if there exists a nonzero b∈Rb \in R such that ab=0ab = 0.

Basically, a zero divisor is a nonzero element that manages to multiply with another nonzero element and still produce 00; something that never happens in Z\mathbb{Z}, Q\mathbb{Q} or R\mathbb{R}. Combining the Fact and the Definition, we get a clean three-way split:

In a finite ring, every element is either 0, a unit, or a zero divisor.\boxed{\text{In a finite ring, every element is either } 0, \text{ a unit, or a zero divisor.}}

It is important to remember that 00 itself is neither a unit nor a zero divisor; it sits in a category of its own.

Example. Find all zero divisors of Z10\mathbb{Z}_{10}.
We check each nonzero non-unit for a nonzero partner that kills it;

2×5=10=0,4×5=20=0,5×2=10=0,6×5=30=0,8×5=40=0.\begin{align*} 2 \times 5 &= 10 = 0, \\ 4 \times 5 &= 20 = 0, \\ 5 \times 2 &= 10 = 0, \\ 6 \times 5 &= 30 = 0, \\ 8 \times 5 &= 40 = 0. \end{align*}

Therefore, the zero divisors of Z10\mathbb{Z}_{10} are {2,4,5,6,8}\{2,4,5,6,8\}; precisely the nonzero elements sharing a common factor with 1010. The remaining nonzero elements {1,3,7,9}\{1,3,7,9\} will turn out to be exactly the units.

You cannot cancel a zero divisor. In Z10\mathbb{Z}_{10} we have 2×1=22 \times 1 = 2 and 2×6=12=22 \times 6 = 12 = 2, so 2x=2y2x = 2y does not imply x=yx = y; cancelling is really multiplying both sides by an inverse, and zero divisors have none. Cancellation in Zn\mathbb{Z}_n is only valid when the element being cancelled is a unit.

Units in Z_n#

We now characterise exactly which elements of Zn\mathbb{Z}_n are units.

Note

Theorem
The element aa is a unit in Zn\mathbb{Z}_n if and only if gcd⁡(a,n)=1\gcd(a,n) = 1.
Proof. (⇐\Leftarrow) Suppose gcd⁡(a,n)=1\gcd(a,n) = 1. By Bézout's identity, there exist integers x,yx,y such that

ax+ny=1.ax + ny = 1.

Reducing both sides modulo nn kills the nyny term, leaving ax=1ax = 1 in Zn\mathbb{Z}_n; so xx (reduced mod nn) is a multiplicative inverse of aa, and aa is a unit.
(⇒\Rightarrow) Suppose aa is a unit, so ab=1ab = 1 in Zn\mathbb{Z}_n for some bb. Then n∣(ab−1)n \mid (ab - 1), i.e. ab−1=knab - 1 = kn for some k∈Zk \in \mathbb{Z}, which rearranges to

ab−kn=1.ab - kn = 1.

Any common divisor of aa and nn divides the left hand side, hence divides 11; so gcd⁡(a,n)=1\gcd(a,n) = 1. ■\blacksquare

a∈Zn∗  ⟺  gcd⁡(a,n)=1.\boxed{a \in \mathbb{Z}_n^* \iff \gcd(a,n) = 1.}

Basically, being a unit mod nn is the same as being coprime with nn. This makes sense: any common factor d>1d > 1 shared between aa and nn can never be multiplied away, because every multiple of aa still carries that factor dd mod nn. In fact if d=gcd⁡(a,n)>1d = \gcd(a,n) > 1, then

a×nd=ad×n=0 in Zn,a \times \frac{n}{d} = \frac{a}{d} \times n = 0 \text{ in } \mathbb{Z}_n,

where nd\frac{n}{d} is nonzero in Zn\mathbb{Z}_n; so every nonzero non-unit of Zn\mathbb{Z}_n is a zero divisor, confirming the three-way split from before.

Note

Corollary
The unit group Zn∗={a∈Zn:gcd⁡(a,n)=1}\mathbb{Z}_n^* = \{a \in \mathbb{Z}_n : \gcd(a,n) = 1\}. That is, the group of units in Zn\mathbb{Z}_n is the set of all natural numbers less than nn that are coprime with nn.

Example. Find Z10∗\mathbb{Z}_{10}^* and the inverse of each of its elements.
By the corollary, Z10∗={1,3,7,9}\mathbb{Z}_{10}^* = \{1,3,7,9\}; the four numbers less than 1010 coprime with 1010. We can confirm each is a unit by finding its inverse directly;

1×1=1,3×7=21=2×10+1=1 in Z10,9×9=81=8×10+1=1 in Z10.\begin{align*} 1 \times 1 &= 1, \\ 3 \times 7 &= 21 = 2\times 10 + 1 = 1 \text{ in } \mathbb{Z}_{10}, \\ 9 \times 9 &= 81 = 8 \times 10 + 1 = 1 \text{ in } \mathbb{Z}_{10}. \end{align*}

This gives us the full table for Z10\mathbb{Z}_{10};

xx 11 33 77 99
x−1x^{-1} 11 77 33 99

Notice how inverses come in pairs; once you know 3−1=73^{-1} = 7, you get 7−1=37^{-1} = 3 for free.

Example. Classify every element of Z12\mathbb{Z}_{12} as 00, a unit, or a zero divisor.
Using the units criterion, we compute gcd⁡(a,12)\gcd(a,12) for each element;

aa gcd⁡(a,12)\gcd(a,12) Status Witness
00 1212 zero —
11 11 unit 1×1=11 \times 1 = 1
22 22 zero divisor 2×6=12=02 \times 6 = 12 = 0
33 33 zero divisor 3×4=12=03 \times 4 = 12 = 0
44 44 zero divisor 4×3=12=04 \times 3 = 12 = 0
55 11 unit 5×5=25=15 \times 5 = 25 = 1
66 66 zero divisor 6×2=12=06 \times 2 = 12 = 0
77 11 unit 7×7=49=17 \times 7 = 49 = 1
88 44 zero divisor 8×3=24=08 \times 3 = 24 = 0
99 33 zero divisor 9×4=36=09 \times 4 = 36 = 0
1010 22 zero divisor 10×6=60=010 \times 6 = 60 = 0
1111 11 unit 11×11=121=111 \times 11 = 121 = 1

Therefore, Z12∗={1,5,7,11}\mathbb{Z}_{12}^* = \{1,5,7,11\} and the zero divisors are {2,3,4,6,8,9,10}\{2,3,4,6,8,9,10\}; every element is accounted for by the three-way split. Notice the curious bonus: every unit in Z12\mathbb{Z}_{12} is its own inverse, since 52=25=15^2 = 25 = 1, 72=49=17^2 = 49 = 1 and 112=121=111^2 = 121 = 1 in Z12\mathbb{Z}_{12}.

When Z_n Is a Field#

We can now answer the question from the start: since a field needs every nonzero element to be a unit, we need every one of 1,2,…,n−11,2,\dots,n-1 to be coprime with nn.

Note

Theorem
Let nn be a positive integer greater than 11. Then Zn\mathbb{Z}_n is a field if and only if nn is prime.
Proof. (⇐\Leftarrow) Suppose nn is prime. Then for every a∈{1,2,…,n−1}a \in \{1,2,\dots,n-1\} we have gcd⁡(a,n)=1\gcd(a,n) = 1, since the only divisors of nn are 11 and nn itself, and n∤an \nmid a. By the units criterion, every nonzero element of Zn\mathbb{Z}_n is a unit, so Zn\mathbb{Z}_n is a field.
(⇒\Rightarrow) Suppose nn is composite, say n=abn = ab with 1<a,b<n1 < a,b < n. Then gcd⁡(a,n)=a≠1\gcd(a,n) = a \neq 1, so aa is a nonzero element with no inverse, and Zn\mathbb{Z}_n is not a field. ■\blacksquare

Zn is a field  ⟺  n is prime.\boxed{\mathbb{Z}_n \text{ is a field} \iff n \text{ is prime}.}

This correlates with what we saw earlier; Z3\mathbb{Z}_3 is a field while Z4\mathbb{Z}_4 is not, matching the fact that 33 is prime while 44 is not.

Example. Z7\mathbb{Z}_7 must be a field since 77 is prime, so every nonzero element of Z7\mathbb{Z}_7 has a multiplicative inverse. We can check this by pairing everything up;

1×1=1,2×4=8=7+1=1 in Z7,3×5=15=2×7+1=1 in Z7,6×6=36=5×7+1=1 in Z7.\begin{align*} 1 \times 1 &= 1, \\ 2 \times 4 &= 8 = 7 + 1 = 1 \text{ in } \mathbb{Z}_7, \\ 3 \times 5 &= 15 = 2 \times 7 + 1 = 1 \text{ in } \mathbb{Z}_7, \\ 6 \times 6 &= 36 = 5 \times 7 + 1 = 1 \text{ in } \mathbb{Z}_7. \end{align*}

xx 11 22 33 44 55 66
x−1x^{-1} 11 44 55 22 33 66

Every nonzero element appears in the bottom row, so Z7\mathbb{Z}_7 is indeed a field.

Example. How many solutions does x2=1x^2 = 1 have in Z8\mathbb{Z}_8?
In a field, x2=1x^2 = 1 factorises as (x−1)(x+1)=0(x-1)(x+1) = 0, and since fields have no zero divisors one of the factors must be 00; so there are at most the two solutions x=±1x = \pm 1. But 88 is not prime, so Z8\mathbb{Z}_8 is not a field, and we should check every element rather than trust the factorisation;

12=1,32=9=8+1=1,52=25=3×8+1=1,72=49=6×8+1=1.\begin{align*} 1^2 &= 1, \\ 3^2 &= 9 = 8 + 1 = 1, \\ 5^2 &= 25 = 3 \times 8 + 1 = 1, \\ 7^2 &= 49 = 6 \times 8 + 1 = 1. \end{align*}

Therefore, x2=1x^2 = 1 has four solutions in Z8\mathbb{Z}_8: x∈{1,3,5,7}x \in \{1,3,5,7\}. The factorisation logic breaks precisely because of zero divisors; taking x=3x = 3 gives (x−1)(x+1)=2×4=8=0(x-1)(x+1) = 2 \times 4 = 8 = 0 with neither factor being zero. In Zn\mathbb{Z}_n for composite nn, a polynomial of degree dd can have more than dd roots, so always check all candidates rather than assuming field behaviour.

Finding Inverses#

Multiplication tables are fine for small nn, but useless for something like Z283\mathbb{Z}_{283}. To find the multiplicative inverse (often just called the inverse) of an element aa in Zn\mathbb{Z}_n, we follow these steps:

  • Find gcd⁡(a,n)\gcd(a,n). If it is not 11, there is no inverse and we stop.
  • Find integers xx and yy such that 1=ax+ny1 = ax + ny; either via the extended Euclidean algorithm, or just by checking small multiples of nn for a number that is 11 away from a multiple of aa.
  • The inverse of aa in Zn\mathbb{Z}_n is the value of its coefficient xx, reduced into Zn\mathbb{Z}_n.

This works because reducing 1=ax+ny1 = ax + ny modulo nn leaves ax=1ax = 1 in Zn\mathbb{Z}_n; the nyny term vanishes.

Example. Find the multiplicative inverse of 66 in Z21\mathbb{Z}_{21}.
First check the gcd;

gcd⁡(6,21)=3≠1.\gcd(6,21) = 3 \neq 1.

Therefore, 66 is not a unit in Z21\mathbb{Z}_{21} and has no multiplicative inverse. (In fact 6×7=42=06 \times 7 = 42 = 0 in Z21\mathbb{Z}_{21}, so 66 is a zero divisor.)

Example. Find 4−14^{-1} in Z21\mathbb{Z}_{21}.
Here gcd⁡(4,21)=1\gcd(4,21) = 1, so the inverse exists. Running the Euclidean algorithm;

21=5×4+1,4=4×1+0.\begin{align*} 21 &= 5 \times 4 + 1, \\ 4 &= 4 \times 1 + 0. \end{align*}

The last nonzero remainder is 11, confirming the gcd. Rearranging the first line for 11;

1=21−5×4=(−5)×4+1×21.\begin{align*} 1 &= 21 - 5 \times 4 \\ &= (-5) \times 4 + 1 \times 21. \end{align*}

So x=−5x = -5, and reducing into Z21\mathbb{Z}_{21} gives −5=16-5 = 16. Checking: 4×16=64=3×21+1=14 \times 16 = 64 = 3 \times 21 + 1 = 1 in Z21\mathbb{Z}_{21}. Therefore, 4−1=164^{-1} = 16 in Z21\mathbb{Z}_{21}.

Alternative solution. Check small multiples of 2121 for a number that is 11 away from a multiple of 44;

1×21+1=22,4∤22,2×21+1=43,4∤43,3×21+1=64=4×16.\begin{align*} 1 \times 21 + 1 &= 22, \quad 4 \nmid 22, \\ 2 \times 21 + 1 &= 43, \quad 4 \nmid 43, \\ 3 \times 21 + 1 &= 64 = 4 \times 16. \end{align*}

So 4×16=3×21+14 \times 16 = 3 \times 21 + 1, i.e. 4×16=14 \times 16 = 1 in Z21\mathbb{Z}_{21}, giving 4−1=164^{-1} = 16 as before. This trial method is often faster when nn is small; the extended Euclidean algorithm is the reliable choice when the numbers are large.

The inverse produced by the algorithm is frequently negative; always reduce it modulo nn before writing the final answer.

Example. Find 193−1193^{-1} in Z283\mathbb{Z}_{283}.
Here trial and error would be painful, so we use the extended Euclidean algorithm in full. First, the Euclidean algorithm to find gcd⁡(193,283)\gcd(193, 283);

283=1×193+90,193=2×90+13,90=6×13+12,13=1×12+1,12=12×1+0.\begin{align*} 283 &= 1 \times 193 + 90, \\ 193 &= 2 \times 90 + 13, \\ 90 &= 6 \times 13 + 12, \\ 13 &= 1 \times 12 + 1, \\ 12 &= 12 \times 1 + 0. \end{align*}

The last nonzero remainder is 11, so gcd⁡(193,283)=1\gcd(193,283) = 1 and the inverse exists. Now back-substitute from the second-last line, replacing each remainder in turn;

1=13−1×12, (rearranging line 4)=13−1×(90−6×13), (substituting line 3)=7×13−1×90=7×(193−2×90)−1×90, (substituting line 2)=7×193−15×90=7×193−15×(283−1×193), (substituting line 1)=22×193−15×283.\begin{align*} 1 &= 13 - 1 \times 12, \text{ (rearranging line 4)} \\ &= 13 - 1 \times (90 - 6 \times 13), \text{ (substituting line 3)} \\ &= 7 \times 13 - 1 \times 90 \\ &= 7 \times (193 - 2 \times 90) - 1 \times 90, \text{ (substituting line 2)} \\ &= 7 \times 193 - 15 \times 90 \\ &= 7 \times 193 - 15 \times (283 - 1 \times 193), \text{ (substituting line 1)} \\ &= 22 \times 193 - 15 \times 283. \end{align*}

So x=22x = 22, which is already in Z283\mathbb{Z}_{283}. Checking: 193×22=4246=15×283+1193 \times 22 = 4246 = 15 \times 283 + 1. Therefore, 193−1=22193^{-1} = 22 in Z283\mathbb{Z}_{283}.

Solving Equations with Inverses#

The whole point of inverses is that they let us divide, which means we can solve linear equations in Zn\mathbb{Z}_n the same way we do in R\mathbb{R}; provided the coefficient is a unit.

Example. Solve 5x=35x = 3 in Z7\mathbb{Z}_7.
Since 77 is prime, 55 is a unit; from the Z7\mathbb{Z}_7 table earlier, 5−1=35^{-1} = 3. Multiplying both sides by the inverse;

5x=35−1×5x=5−1×3x=3×3=9=2 in Z7.\begin{align*} 5x &= 3 \\ 5^{-1} \times 5x &= 5^{-1} \times 3 \\ x &= 3 \times 3 \\ &= 9 \\ &= 2 \text{ in } \mathbb{Z}_7. \end{align*}

Checking: 5×2=10=7+3=35 \times 2 = 10 = 7 + 3 = 3 in Z7\mathbb{Z}_7. Therefore, x=2x = 2 is the unique solution; uniqueness is guaranteed because we multiplied by an inverse, which is a reversible step.

Example. Solve 6x=36x = 3 in Z21\mathbb{Z}_{21}.
Here gcd⁡(6,21)=3≠1\gcd(6,21) = 3 \neq 1, so 66 has no inverse and we cannot just divide; but that does not mean there are no solutions. The equation says 21∣(6x−3)21 \mid (6x - 3), and since 33 divides every term we can factorise the whole congruence by 33;

6x≡3(mod21)2x≡1(mod7).\begin{align*} 6x &\equiv 3 \pmod{21} \\ 2x &\equiv 1 \pmod 7. \end{align*}

Now gcd⁡(2,7)=1\gcd(2,7) = 1, so 22 is invertible mod 77 with 2−1=42^{-1} = 4 (since 2×4=8=12 \times 4 = 8 = 1 in Z7\mathbb{Z}_7);

2x≡1(mod7)x≡4(mod7).\begin{align*} 2x &\equiv 1 \pmod 7 \\ x &\equiv 4 \pmod 7. \end{align*}

Lifting back to Z21\mathbb{Z}_{21}, the elements congruent to 44 mod 77 are x∈{4,11,18}x \in \{4, 11, 18\}. Checking each: 6×4=24=36\times 4 = 24 = 3, 6×11=66=3×21+3=36 \times 11 = 66 = 3 \times 21 + 3 = 3, and 6×18=108=5×21+3=36 \times 18 = 108 = 5 \times 21 + 3 = 3 in Z21\mathbb{Z}_{21}. Therefore, the equation has three solutions, x∈{4,11,18}x \in \{4,11,18\}.

The decision process here is worth internalising: check gcd⁡(a,n)\gcd(a,n) first. If it is 11, invert and get a unique solution; if d=gcd⁡(a,n)>1d = \gcd(a,n) > 1, then solutions exist only when dd divides the right hand side, in which case dividing the whole congruence (including the modulus!) by dd gives exactly dd solutions in Zn\mathbb{Z}_n.

Irreducible and Prime Elements#

Now that we have encountered units, we can refine our earlier definitions of irreducible and prime elements so that they make sense in any ring.

Note

Definition
An irreducible element of a ring RR is any p∈Rp \in R such that both

  • p≠0p \neq 0 and p∉R∗p \notin R^*, and
  • whenever p=abp = ab for elements a,b∈Ra,b \in R, we must have a∈R∗a \in R^* or b∈R∗b \in R^*.

Note

Definition
A prime element of a ring RR is any p∈Rp \in R such that both

  • p≠0p \neq 0 and p∉R∗p \notin R^*, and
  • whenever p∣abp \mid ab for elements a,b∈Ra,b \in R, we must have p∣ap \mid a or p∣bp \mid b.

Basically, irreducible means "cannot be factorised except trivially" (a unit times something is a trivial factorisation, since units can always be absorbed), while prime means "whenever it divides a product it divides one of the factors". These used to look like the same idea; in Z\mathbb{Z} they coincide, which is why we never needed to distinguish them before. The unit condition also explains our old exclusions: for R=NR = \mathbb{N} we banned p=0,1p = 0, 1 since N∗={1}\mathbb{N}^* = \{1\}, and for R=ZR = \mathbb{Z} we banned p=0,±1p = 0, \pm 1 since Z∗={−1,1}\mathbb{Z}^* = \{-1,1\}.

Example. No element of Z5\mathbb{Z}_5 is irreducible nor prime.
Since 55 is prime, Z5\mathbb{Z}_5 is a field by the field theorem; so every element is either 00 or a unit, and nothing survives the first bullet point of either definition.

Example. Show that in Z6\mathbb{Z}_6, the element 22 is prime but not irreducible.
First, the setup: Z6∗={1,5}\mathbb{Z}_6^* = \{1,5\} (the elements coprime with 66), and 2≠02 \neq 0 with 2∉Z6∗2 \notin \mathbb{Z}_6^*, so 22 passes the first bullet of both definitions.

Not irreducible. We need a factorisation of 22 using no units. Notice that

2×4=8=6+2=2 in Z6,\begin{align*} 2 \times 4 &= 8 \\ &= 6 + 2 \\ &= 2 \text{ in } \mathbb{Z}_6, \end{align*}

so 2=2×42 = 2 \times 4 where gcd⁡(2,6)=2\gcd(2,6) = 2 and gcd⁡(4,6)=2\gcd(4,6) = 2; neither factor is a unit. Therefore, 22 is not irreducible in Z6\mathbb{Z}_6.

Prime. The multiples of 22 in Z6\mathbb{Z}_6 are 2×{0,1,2,3,4,5}={0,2,4}2 \times \{0,1,2,3,4,5\} = \{0,2,4\}, so 2∣x2 \mid x in Z6\mathbb{Z}_6 exactly when x∈{0,2,4}x \in \{0,2,4\}. Suppose 2∤a2 \nmid a and 2∤b2 \nmid b, i.e. a,b∈{1,3,5}a,b \in \{1,3,5\}. Checking all products of these residues;

1×1=1,1×3=3,1×5=5,3×3=9=3,3×5=15=3,5×5=25=1 in Z6,\begin{align*} 1 \times 1 = 1, \quad 1 \times 3 = 3, \quad 1 \times 5 &= 5, \\ 3 \times 3 = 9 &= 3, \\ 3 \times 5 = 15 &= 3, \\ 5 \times 5 = 25 &= 1 \text{ in } \mathbb{Z}_6, \end{align*}

every product lands back in {1,3,5}\{1,3,5\}, so 2∤ab2 \nmid ab. By the contrapositive, 2∣ab2 \mid ab forces 2∣a2 \mid a or 2∣b2 \mid b. Therefore, 22 is prime in Z6\mathbb{Z}_6, despite not being irreducible. Prime and irreducible are genuinely different notions in a general ring; they only happen to agree in familiar rings like Z\mathbb{Z}.