Proving that $nb \text{ (mod m)}$ reaches all values $\{0 \dots (m-1)\}$ if $n$ and $m$ are relatively prime

I am trying to prove the frobenius coin problem which requires me to prove the following lemma:

If $n$ and $m$ are relatively prime and $b$ is any integer, then the set of all possible values of $$nb \text{ (mod m)} \text{ will be } \{0, 1, 2, \dots, (m-1)\}$$


I have so far that the set of all values of $b \text{ (mod m)}$ for any $b$ will be $\{0, \dots, (m-1)\}$, and that

$$nb \text{ (mod m)} = [n \text{ (mod m)}\cdot b \text{ (mod m)]}\text{ (mod m)}$$

Let $n \text{ (mod m)} = p$. Then I need to prove that when the elements of the set $\{0, p, 2p, 3p, \dots, (m-1)p\}$ are reduced modulo $m$, then the result is just $$\{0, 1, 2, \dots, (m-1)\}$$ However, I am unsure how to do this. Can someone give me a hint?


So here $n$ and $m$ are fixed relatively prime integers. We will show that as $b$ ranges from $0$ to $m-1$, the numbers $bn\bmod m$ range over all the integers from $0$ to $m-1$.

The key is that if $0\le x\lt y\le m-1$, then $xn\bmod m$ and $yn\bmod m$ are different.

Suppose to the contrary that $xn\bmod m=yn\bmod m$. Then $m$ divides $yn-xn$, that is, $m$ divides $(y-x)m$, But since $m$ and $n$ are relatively prime, we must have $m$ divides $y-x$. This is impossible, since $1\le y-x\le m-1$.

Since the values taken on by $bn\bmod m$ as $b$ ranges over the numbers from $0$ to $m-1$ are all different, and all between $0$ and $m-1$, they must be all the numbers from $0$ to $m-1$.


Consider the ring $\mathbb{Z}_m$, then as hcf$(n,m) = 1$, $n$ is invertible and in particular the map

$$ f: \mathbb{Z}_m \to \mathbb{Z}_m $$ given by $$ f(b) = nb $$ is an invertible ring homomorphism, so ker$f = 0$ and so im$f = \mathbb{Z}_m$ by counting the size of the domain and range of $f$.

So the set of all possible values of $nb$ (mod $m$) will be ${0,1,2,…,(m−1)}$


Because $(n,m)=1$ we know by the Euclidean algorithm that there exist integers $x,y$ such that $mx+ny=1$

But then if we look at the set of residue classes modulo $m$, $R_m=\{[0],[1],[2],\ldots, [m-1]\}$ more commonly denoted $\{0,1,2,\ldots, m-1\}$, we see that

$$\begin{cases} f: R_m\to R_m \\ s\mapsto ns\pmod m\end{cases}$$

is a function.

The function

$$\begin{cases} g:R_m\to R_m \\ s\mapsto ys\pmod m\end{cases}$$

is verified to be the inverse function to $f$, since $ny\equiv 1\mod m$, hence $f$ is a permutation of the residue classes by definition. But a permutation is a bijection, that is a $1$-$1$ and onto function, so that the image is all of $R_m$, i.e. the set of values of $[ns]$ (which is the image of the function by definition of $f$) is all of $R_m$.