Number of invertible elements in a ring $\mathbb{Z}_n$.

1.5k Views Asked by At

I know that:

a number $a\in\mathbb{Z}_n$ is invertible iff $\text{gcd}(a,n)=1$.

So say $n=2019$. How can I find the number of invertible elements in $\mathbb{Z_{2019}}$? Surely testing $2019$ numbers for primality is out of the question.

Also, if $a=32$, what is its inverse? In my book they state that

An inverse in modular arithmetic is a number $a\in\mathbb{Z}_n$ if there exists a number in $\mathbb{Z}_n$ such that if multiplied by $a$ gives $1$.

So from this I understand that I need to find an $x\in\mathbb{Z}$ such that

$$32\cdot x\equiv 1(\text{mod}\ 2019).$$ This is the same as solving the diophantine equation

$$32x=1+2019y\Leftrightarrow32x-2019y=1,$$

which has trivial solution $(x,y)=(-694,-11)$. So the inverse of $32$ is $-694?$

1

There are 1 best solutions below

9
On BEST ANSWER

For the second question, your reasoning is correct. Indeed the inverse of $32$ in $\Bbb{Z}/2019\Bbb{Z}$ is $-694$, though perhaps a representative in the interval $[0,2018]$ is preferred.

For the first question, it helps to first know the prime factors of $2019$. It is not hard to check that $2019=3\times673$ and that $3$ and $673$ are prime. Then an integer in the interval $[0,2018]$ is coprime to $2019$ if and only if it is not divisible by $3$ and not divisible by $673$. I leave it to you (for now) to count how many such integers there are.