Find all values such that $\phi(n)=n-2$ I'm currently working in the following Euler's theorem exercise:

Find all values such that $\phi(n)=n-2$

A simple calculation gave me the first one based on the formula $\phi(n^k) = n^k-n^{k-1}$, so with $n=4$, checking similar questions here I'm trying to find other numbers based on:
$$\phi(n)=n\prod_{p|n}(1-1/p)$$
But I've been unable to use it to solve my problem, any help will be really appreciated.
 A: If $\phi(n)=n-2$, there are exactly two integers between $2$ and $n$ that have a common factor with $n$. For $n>1$ (which we obviously need), $n$ is one of them. That leaves one other.
If $n$ is prime, then there are no others and $\phi(n)=n-1$. Nope.
If $n$ is not prime, there's some prime $p<n$ such that $p|n$. Then $p$ and $\frac np$ both have a common factor with $n$, and are both different from $n$. If $p\neq \frac np$, that's three integers with a common factor right there. Nope.
That leaves the case $n=p^2$ for $p$ a prime. In this case, we can easily see that $\phi(p^2)=p^2-p$, leaving $p=2$ and $n=4$ the only option. There is only one solution to $\phi(n)=n-2$, namely $n=4$.
A: If $\phi(n)=n-2$ and $q$ is a prime divisor of $n$, then
$$n-2=\phi(n)=n\prod_{p\mid n}(1-1/p)\le n(1-1/q)=n-{n\over q}$$
which implies $n\le2q$.  This in turn implies either $n=q$ or $n=2q$.  But if $n=q$, then $\phi(n)=n-1$, not $n-2$, and if $n=2q$ with $q\not=2$, then $\phi(n)=q-1\not=2(q-1)=n-2$. The only remaining possibility is $n=2q$ with $q=2$.
