Properties of Euler's phi function If $\phi(n) =n-2$ then $n=4$. I need a hint to prove this statement. "This is my first Number Theory course."
 A: Let $n=2^km$, where $\gcd(m,2) = 1$. If $k>0$, we then have
$$\phi(n) = \phi(2^k)\phi(m) = 2^{k-1} \phi(m)$$
We are given that
$$\phi(n) = n-2 \implies 2^{k-1} \phi(m) = 2\left(2^{k-1}m-1\right) \implies \phi(m) =2m-\dfrac1{2^{k-2}}$$
We also have $\phi(m) \leq m$. Hence, we need
$$2m-\dfrac1{2^{k-2}} \leq m \implies m \leq \dfrac1{2^{k-2}}$$
If $k>2$, we then have $m <1$, which is not possible. Hence, $k=1$ or $2$. Since $\gcd(m,1)=1$, we have $m=1$. This boils down the value of $n$ to $n=4$.
If $k=0$, we then have $\phi(m) = m-2$, where $\gcd(m,2) = 1$. If $m>8$, this is not possible, since we have three numbers $2,4,8$ relatively prime to $m$. Hence, $m$ is an odd number less than $8$. Hence, conclude again that this is not possible.
A: Obviously $n>1$, hence for some prime $p$ we have $p|n$.
Now observe that if $n>2p$, then $(n,n),(n,p),(n,2p)\neq1$ so $\varphi(n)\le n-3$ which contradicts.
Hence $n\le 2p$ but $n\neq p$ because in this case $\varphi(n)=n-1$, with $p|n$ we have $n=2p$ now observe that if $p\neq2$, then $(n,n),(n,p),(n,2)\neq1$ which contradicts because in this case again $\varphi(n)\le n-3$. So $p=2$ as we want...
