Show that if $q$ is prime and divides $m$, then $\phi(qm) = q\phi(m)$, while if $q$ doesn't divide $m$, then $\phi(qm) = (q-1)\phi(m)$ where $\phi$ is the Euler totient function, i.e. $\phi(m) = n \prod_{i=1}^n \left(1 - \frac{1}{p_i}\right)$ with $m=p_1^{e_1} \times \cdots \times p_k^{e_k}$
I am a bit stuck with this.
I have tried this: $$\phi(qm) = qm \prod_{i=1}^n \left(1 - \frac{1}{p_i}\right)\left(1-\frac{1}{q}\right) = q\left(1-\frac{1}{q}\right)m\prod_{i=1}^n \left(1 - \frac{1}{p_i}\right)$$However, this gives the second result in the case where $q$ doesn't divide $m$. I can't seem to get the first result and I don't think I have used so far that $q$ does not divide $m$.
The formula $\phi(qm) = q\phi(m) - \phi(m)$ seems to suggest that if $q$ divides $m$, then $\phi(m) = 0$, which I can't also seem to understand, as I think $\phi(m)$ is independent of $q$...?
Note that if $q \mid m$ then we have that $q$ appears in the prime factorization of $m$. So we get that:
$$\phi(qm) = qm\left(1 - \frac 1q\right)\left( 1 - \frac 1{p_1}\right) \cdots \left(1 - \frac 1{p_n}\right) = q\phi(m)$$
If $q \not \mid m$ it doesn't appear in the prime factorization then we have that $\phi(m) = m\left( 1 - \frac 1{p_1}\right) \cdots \left(1 - \frac 1{p_n}\right)$, so we get that $\phi(qm) = q\left(1 - \frac 1q \right)\phi(m) = (q-1)\phi(m)$