Given that if $n = p_1^{\alpha_1}\cdots p_r^{\alpha_r}$ we know that $$\phi(n) = p_1^{\alpha_1 -1}(p_1 - 1) \cdots p_r^{\alpha_r -1}(p_r-1). \quad (1)$$
So, if $\phi(n)$ was given, the method of searching for all $n$ first finds the list of prime factors of $\phi(n)$, then we just have to shortly play with the primes to find the numbers. Unfortunately, using this method, I'm not able to find all of the numbers $n$.
Example.
Given $\phi(n) = 42 = 2\cdot 3 \cdot 7$, using $(1)$ I can find a set of primes $p_i \in \{2,3,7,43\}$, looking at the primes if $43$ is taken into consideration it is obvious that number $n = 43k$ where $k=2^\alpha 3^\beta 7^\gamma$, then $$\phi(43k) = \phi(43)\phi(k)$$ and since $\phi(43)=42$ it is obvious that $k \in \{1,2\}$. Two numbers found!
How to find the rest?
This is where I get stuck...
Now, if we say that $$n=2^\alpha 3^\beta 7^\gamma \implies \phi(n) = 2^{\alpha-1} 3^{\beta-1}7^{\gamma-1} \cdot 1 \cdot 2 \cdot 2 \cdot 3,$$ so, $$2^{\alpha+1} 3^{\beta}7^{\gamma-1} = 2 \cdot 3 \cdot 7 = 42, $$ solving the equation I get $n = 147$ which isn't correct.
Where's my mistake, if there is one?
Thank you!
All of $2,3,7$ cannot be in the prime factorization of $n$ since then, as you noted, we have $(3 \cdot 2 \cdot 2) = 12$ in our phi calculation but $42/12$ is not an integer!
Do casework on which two primes, or one prime, are represented.
(Also, Wolfram Alpha gives lets you calculated phi values. Just type $\phi(n) = 42$ and it returns all possible $n's$.)