Help understanding proof. Show that $\varphi(n)=\frac{1}{2}n$ if and only if $n=2^{k}$ for some $k \geq 1$ I have this proof - I can do the second direction (starting with "on the other hand") and I understand some of the logic in this first direction...but I can't figure out WHY he did the first step? I want to know mostly why "we can write $n=2^{k}p^{m}$" at the beginning? Also, why does the non-existence of such $p$ imply the result?
Proof:
Firstly, let $\varphi(n)=\frac{1}{2}n$, in which case we can write $n=2^{k}p^{m}$ so that $\varphi(2^{k}p^{m})(1=\frac{1}{2})(1-\frac{1}{p})=\frac{1}{2}2^{k}p^{m}$. But, when attempting to solve for $p$ in the factor $(1-\frac{1}{p})=1$, we find that we want to find $p$ such that$-\frac{1}{p}=0$, for which there exists no number $p$. So, $n$ must contain only $2$s. Thus, $n=2^{k}$ for some $k$.
On the other hand, let $n=2^{k}$ for some integer $k$. Then we can calculate
$\varphi(n)=2^{k}(1-\frac{1}{2})=2^{k}(\frac{1}{2})=\frac{1}{2}n 
$
 A: It looks as if the author of the proof assumes (erroneously) that $n$ can have at most one other prime factor besides 2. He or she should really have written $n = 2^k p_1^{m_1} p_2^{m_2} \cdots p_\ell^{m_\ell}$. But the multiplicativity of the totient function still works for multiple factors, as long as they're pairwise coprime: \begin{align*}
\phi(n) &= \phi(2^k) \phi(p_1^{m_1}) \cdots \phi(p_\ell^{m_\ell}) \\
&= 2^k \left(1-\frac{1}{2}\right) p_1^{m_1} \left(1 - \frac{1}{p_1}\right) \cdots p_\ell^{m_\ell} \left(1 - \frac{1}{p_\ell}\right) \\
&= n \left( 1 - \frac{1}{2} \right) \left( 1-\frac{1}{p_1}\right) \cdots \left( 1 - \frac{1}{p_\ell} \right),
\end{align*}
and this can't equal $n/2$ if $\ell > 0$ (i.e. if $n$ has a prime divisor besides $2$).
A: Let $P(n)$ be the largest prime divisor of $n$. Since $\varphi(n)$ is a multiplicative function, we have
$$ \frac{\varphi(n)}{n}=\prod_{p\mid n}\frac{p-1}{p} \tag{1}$$
where the RHS of $(1)$ is a rational number of the form $\frac{A}{B}$, with $\gcd(A,B)=1$. 
We have that $P(n)$ is a divisor of $B$ but is not a divisor of $A$, since $P(n)\nmid (p-1)$ for any prime divisor of $n$ that is less than $P(n)$. It follows that $\frac{\varphi(n)}{n}=\frac{1}{2}$ implies $P(n)=2$, i.e. $n=2^k$.
