We present an algorithm to invert the Euler function $\varphi(m)$. The algorithm, for a given integer $n\ge 1$, in polynomial time ``on average'', finds theset $\Psi(n)$ of all solutions $m$ to the equation $\varphi(m) =n$. In fact, in the worst case the set $\Psi(n)$ is exponentially large and cannot be constructed by a polynomial time algorithm. In the opposite direction, we show, under some widely accepted number theoretic conjecture, that the problem of deciding whether $\varphi(m) =n$ for some $m$ is {\bf NP}-complete. Finally, we establish close links between the problem of inverting the Euler function and the integer factorisation problem.