I found this exercise in Beachy and Blair: Abstract algebra:
Find all natural numbers $n$ such that $\varphi(n)=2$, where $\varphi(n)$ means the totient function.
My try:
$\varphi(n)=2$ if $n=3,4,6$ and I think that no other numbers have this property. So assume $n>7$.
Case 1: $n$ is prime, since $\varphi(n)=n-1$ for primes, no numbers here will have the desired property
Case 2: $n$ is of the form $n=p^k$ for some prime $p$ and $k\in\mathbb{N}, k\ge 2$. By Eulers formula we get $$ \varphi(n)=p^k-p^{k-1} $$ which clearly is greater than $2$ since $n>7$.
Case 3: $n$ is the product of different primes and is squarefree (each prime comes up at most once in the prime factorisation of $n$). Assume $$ n=\prod_{i=1}^{m} p_i $$ by Eulers formula $$ \varphi(n)=n\prod_{p_i \ prime \ factor}\Big(1-\frac{1}{p_i}\Big) $$ which gives $$ \varphi(n)=p_1p_2\cdot\ldots\cdot p_m\Big(1-\frac{1}{p_1}\Big)\Big(1-\frac{1}{p_2}\Big)\cdot \ldots\cdot \Big(1-\frac{1}{p_m}\Big) $$ rearranging and multiplying out gives $$ (p_1-1)(p_2-1)\cdot\ldots\cdot (p_m-1) $$ which once again has to be greater than $2$ since $n>7$.
Case 4: $n$ is a product of different primes and not squarefree. This is similar to Case 3 but we get some more factors in the product so if there were no integers in Case 3 there cannot be here eighter.
Now my first question is: Is my reasonning correct? Ususally when I have to divide the solution up into so many cases I feel that I haven't grasped the problem properly, but I couldn't come up with anything better.
Any suggestions?
Thank you in advance