Why is the set of integers modulo 3 a field? Also why is integers modulo prime a field?

It is true that that $\mathbb{Z}$ does not, in general, contain inverses. However, the set of integers modulo $p$ a prime is a very different structure than $\mathbb{Z}$. For an example, let's use $p=3.$

Let's call the set of integers modulo 3 by $\mathbb{F}_3.$ It has three elements, which we will call $\{\overline{0},\overline{1},\overline{2}\}.$ Don't confuse these with $0, 1,2\in\mathbb{Z},$ as they're quite different! One way to think of them is that each one represents the set of all integers which has the given remainder when divided by 3. For instance, $\overline{2}$ denotes the set of all integers which have remainder $2$ when divided by $3$. Equivalently, $\overline{2}$ denotes the set of integers which are congruent to $2$ modulo $3$.

Now we can perform standard modular arithmetic to determine the addition and multiplication tables for this set. We find that $\overline{1}*\overline{1}=\overline{1},$ and $\overline{2}*\overline{2}=\overline{4}=\overline{1}.$ Thus, both of the nonzero elements have inverses! Note that in computing the multiplication I mentioned a new element $\overline{4}$ that looks out of place. But it's okay, because we know that $4\equiv 1\bmod 3.$ So we can always do normal arithmetic under the bar and then simplify it afterward. This is why modular arithmetic is so easy!

We see that this can happen in a finite field because there isn't room for numbers to keep getting bigger and bigger, as there is in $\mathbb{Z}.$ Instead, multiplication "wraps around" until it gets to $\overline{1}$ and you find your inverse.

But be careful! This trick only works because $p$ was prime. As we know, the product of any two integers with magnitude less than $p$ will never be a multiple of $p$, and thus the product of any two nonzero elements of $\mathbb{F}_p$ will never be zero (do you see why this works?). However, suppose that instead of $p$ we chose some $n=pq$ a product of two primes $p$ and $q$. Then, we would not be able to find an inverse for $p$, because in the integers modulo $n$, we have that $\overline{p}*\overline{q}=\overline{pq}=\overline{0}.$ So if there were some $\overline{m}$ such that $\overline{p}*\overline{m}=1,$ then we would have $\overline{q}=\overline{p}*\overline{m}*\overline{q}=\overline{0},$ a contradiction!

That $p$ does not have any divisors is precisely equivalent to the condition that $\overline{p}=\overline{0}$ does not have divisors in the integers modulo $p$, and we recall that an element has an inverse (i.e., it is a unit) precisely if it does not divide $0$, which in this case is $p$.


The set of integers modulo 3 is {0,1,2}. For + we have:

+   0 1 2
0   0 1 2
1   1 2 0
2   2 0 1

Notice that 1 + 2 = 3 = 0 (mod 3).

Also for multiplication:

*  0 1 2
0  0 0 0
1  0 1 2
2  0 2 1

So: -1 = 2 and 1/1 = 1 and 1/2 = 2. It is a Field.