Where $\phi(n)$ is Euler's phi function that counts the number of relatively prime integers less than or equal to n.
I've been able to compute that 3,4,6 all have only 2 relatively prime integers less than or equal to them, however I'm unsure how to prove that there are indeed no others. While I am certain that this is the case, how can this be proved rigorously?
The trickiest thing about this proof is figuring out how to organize the casework. Here's one way to do it:
If $n = 2^k$ is a power of two then $\varphi(n) = 2^{k-1}$ so we see that we can only have $k = 2$, so $n = \boxed{4}$.
Otherwise, $n$ has some odd prime power factor $p^k$, and then $\varphi(n)$ must be divisible by $\varphi(p^k) = (p-1) p^{k-1}$. Since $p$ is odd, $2 \mid (p-1)$, so $\varphi(p^k)$ will be strictly larger than $2$ unless $p = 3, k = 1$. So now we must have $n = 2^k \cdot 3$, which gives $\varphi(n) = 2^k$ for $k \ge 1$, hence $k = 1$, so $n = \boxed{6}$, or $\varphi(3) = 2$ for $k = 0$, so $n = \boxed{3}$.
Exercise. Generalize this argument to show that for any $m$ there are finitely many $n$ such that $\varphi(n) = m$. Can you compute which $n$ these are for other small values of $m$, say $m = 4$ or $m = 6$? (Hint: prove it in two stages. First prove that there are only finitely many possible prime factors for $n$. Second prove that the exponent of each of these prime factors is bounded. Working through the small cases $m = 4$ and $m = 6$ first would be a good idea as a warmup.)