TITLE: Number Theory: Find all solutions of $\phi(n)=16$ and $\phi(n)=24$
QUESTION [7 upvotes]: I have this homework problem assigned and I'm a little confused in solving it:
Find all solutions of $\phi(n)=16$ and $\phi(n)=24$ (where $\phi(n)$ is the Euler phi-function).
The hint that's provided says:
If $n=p_1^{k_1}p_2^{k_2}\cdots p_r^{k_r}$ satisfies $\phi(n)=k$, then $n=\frac{k}{\prod (p_i-1)}\prod p_i$. Thus the integers $d_i=p_i-1$ can be determined by the conditions (1) $d_i\mid k$, (2) $d_i+1$ is prime, and (3) $\frac{k}{\prod d_i}$ contains no prime factor not in $\prod p_i$.
I'm ok with proving the statements in the hint and I know how to get them, but I'm not sure how to apply them to solve the problem.

REPLY [2 votes]: One  obvious candidate is 17, as it is prime and one more than 16.
Take  $16=4\times2\times2$. Can each of these 3 terms be phi of distinct prime powers? Every power of  2 is the phi of next power of 2. The 2 can be realised as phi of 3. Next 2 is not possible. So $16=\phi(8)\times \phi(3)\times ?$, Now we are stuck.
Take another factorization $16=4\times 4=\phi(8)\times \phi(5)$, with gcd(8,5)=1. So $\phi(40)=\phi(8\times5)=16$. 
This way one can find by listing all possible factorizations: You only need to check if individual factors are phi values of prime powers; and if so do they correspond to different primes.