Q. If $m$ and $n$ are two positive integers and $f:A\to A,$ where $A=\{0,1,2,3,...,m-1\},$ is defined by $f(x)= nx\pmod m.$ Find the condition on $n$ and $m$ which ensures that $f$ is one-to-one and onto.
My attempt: Here $f^{-1}$ must exist if $f$ is a bijection. Now as $f$ maps $x$ to $nx$ under modulo $m$ so $f^{-1}$ must map $x$ to $n^{-1}x$ under modulo $m.$ But in $\mathbb Z_m$(or here $A$), $n^{-1}$ will exist iff $\gcd(m,n)=1.$ So I think the required condition should be that $m$ and $n$ are relatively prime. (I don't know what the actual answer is!)
I have just started with number theory and discrete mathematics this semester. So I don't have much knowledge to deal with such type of questions involving moduler arithmetic. So kindly guide me saying that whether my approach is correct or not. If not, please suggest me a way to reach the answer to this question or if it is correct, then can we reach the same conclusion using a different approach? I would love to know about your insights. Thanks in advance...