Find all $n$ such that $\phi(n)/n=1/2$. [duplicate]

Let $\phi$ be the Euler's phi function.I want to find those $n$ for which $\frac{\phi(n)}{n}=1/2$.I know that $n=2^k$ will work.But can we show that these are the only integers such that this holds?

Addendum

I have tried to show like this,$n=2^\alpha p_1^{\alpha_1}...p_k^{\alpha_k}$,where $p_1,...,p_k$ are odd prime divisors ,then $\phi(n)=2^{\alpha-1}p_1^{\alpha-1}...p_k^{\alpha_k-1}(p_1-1)...(p_k-1)$.So,$\phi(n)/n=\frac{(p_1-1)...(p_k-1)}{2p_1p_2...p_k}$,now $2$ gets cancelled with $2 $ in $(p_1-1)$ and thus denominator cannot contain $2$ in reduced form.


Solution 1:

Just to do this without factoring into primes, note that $\phi(n)$ is always an integer, so in order to have $\phi(n)=n/2$, $n$ must be even. But in that case the only numbers less than $n$ relatively prime to $n$ are odd numbers, which means all of them must be relatively prime to $n$. So $n$ cannot be divisible by any odd prime. Thus $n$ must be a power of $2$.

Solution 2:

Factorize $n$ as $p_1^{e_1}...p_k^{e_k}$. Since $$ \varphi (n) = n \prod_{i=1}^{k}\left( 1-\frac{1}{p_i} \right) \implies \frac{\varphi (n)}{n} =\prod_{i=1}^{k} \left( 1-\frac{1}{p_i} \right) , $$ it suffices to show that the product is never $1 /2$ when $n$ contains prime factors other than $2$. Indeed, assuming all $p_i$'s are odd, from $$ \prod_{i=1}^{k} \left( 1-\frac{1}{p_i} \right) = \frac{\prod_{i=1}^{k} (p_i-1)}{\prod_{i=1}^{k} p_i} $$

we see that $2^{k}$ divides the numerator whereas the denominator is odd. Clearly this ratio can never be $1 /2$. (The case where one of them is $2$ is analogous; the denominator still cannot contain more powers of $2$.)