There are $\frac{m}{gcd(m,x)}$ distinct elements in the set $\{ax\phantom{\rule{0.444em}{0ex}}(\mathrm{mod}\phantom{\rule{0.333em}{0ex}}m):a\in \{0,...,m-1\}\}$

I have only known these by using a computer to generate the number of distinct elements. But I am not sure how to prove this conjecture.

And is there any way that we can connect this problem to Euler's phi function so that we can simply use properties of $\varphi $ function to prove it?

And can we also use some counting principle here to give an exact answer?

I have only known these by using a computer to generate the number of distinct elements. But I am not sure how to prove this conjecture.

And is there any way that we can connect this problem to Euler's phi function so that we can simply use properties of $\varphi $ function to prove it?

And can we also use some counting principle here to give an exact answer?