How can we find $m_2$ such that $m \equiv m_1 m_2 \pmod n$ ? Let $m, m_1 \in (\mathbb{Z}/n\mathbb{Z})^{\times}$. 
How can we find $m_2$ such that $m \equiv m_1 m_2 \pmod n$ ?? 
Coud you give me some hints?? 
 A: Hint $\,\ \exists x\!:\ ax \equiv b \pmod n \iff \exists x,y\!:\ ax+ny = b \iff (a,n)\mid b,\ $ by Bezout.
When it holds $\,\color{#c00}{(a,n)c = b},\,$  so scaling $ $ Bezout: $\, aj+nk = \color{#c00}{(a,n)}\ $ by $\,\color{#c00}c\,$ yields a solution.
A: It does not always exist if $m$ and $m_1$ are arbitrary integers, more precisely, it exists if and only if $g\mid m$, where $g=\gcd(n,m_1)$ (however, this is the case in your problem since by definition $m_1$ is invertible modulo $n$). You can try to prove this by your own using the fact that for every pair of integers $p,q$ there exist integers $x,y$ such that
$$\gcd(p,q)=xp+yq$$
(those integers can be found using euclidean algorithm which gives the algorithm you're looking for).
A: First notice that it doesn't always have a solution (for example, let $n=6$, $m_1=2$ and $m=1$). It has a solution $iff$ $gcd(n,m_1)|m$.
Supposing that $gcd(n,m_1)|m$, you can always solve this equation.
First consider the case in which $gcd(n,m_1)=1$.
There are several ways to solve that, but one is to find the inverse of $m_1 \ mod\ n$. i.e. to find $m_2^*$ such that $m_1.m_2^*=1 \ mod \ n$.$^+$ Then it's not hard to see that your answer will be the remainder of division of $m_2^*.m$ by $n$.
For the case in which $gcd(n,m_1)=d>1$, you could divide the equation by $d$, and solve something like $m_1'.m_2'=m/d \ (mod \ n/d)$ in which $m_1'=m_1/d$ and $m_2'=m_2/d$, just like above. Then your answers for $m_2$ will be $m_2'$,$m_2'+m/d$,$m_2'+2m/d$,...$m_2'+(d-1)m/d$.
$^+$to solve the equation $ax=1 \ mod \ n$ when $gcd(n,a)=1$, use Euclid algorithm to find s and t such that $ns+at=1$ (Bezout's theorem), then you will have $x=t \ mod \ n$.
