Came across this question in Number Theory.
Let $\phi$ denote Euler's totient function; Show that the only solution to $\phi(n) =n-2$ is $n=4$
My workings so far have included, firstly proving that $4$ is indeed a solution, I have also noted that the solution cannot be prime because $\phi(p)=p-1$.
From here, could I note that my solution must be composite, and the only way in which it could have only 2 numbers which are not coprime would be if n is a square number?
Not sure how to prove this completely though.
Also, could I incorporate the fact that $\phi(p^k)=p^{k-1}(p-1)$ in any way?
All help greatly appreciated. Thanks.
The equation $\phi(n) = n - 2$ means that there are $n - 2$ numbers in $\{1, 2, \dots, n\}$ that are relatively prime to $n$. In other words, there are exactly two numbers in $\{1, 2, \dots, n\}$ that are not relatively prime to $n$. One of them of course is $n$ itself. So there is exactly one other number, in $\{2, \dots, n-1\}$, which shares any factors in common with $n$.
Now as you observed, $n$ cannot be prime (because then there would be none). So $n$ is composite, and therefore has some prime factor $p$. This is one number with which $n$ shares a common factor, and if $n > 2p$, then $2p$ is another such number. So $n = 2p$. We now know that $n$ is even, i.e., $2$ is a prime factor $p$ of $n$, and from $n = 2p$, we get $n = 2\times2 = 4$.