Question regarding usage of residue theorem in a specific case I'm looking over the solution of an exercise in a course I'm taking and there's something I simply don't understand. Let $f(z)=\pi\cot(\pi z)$ and $\varphi(z) = \frac{1}{z^2}$.  $f$ has poles of order $1$ in the points $k\in\mathbb{Z}$ and $\varphi$ has a pole of order $2$ at $0$. Now in the solution of the exercise it is written that from the residue theorem the following holds:
$$\frac{1}{2\pi i} \int_\gamma f\cdot\varphi \, dz=\operatorname{Res} (f\varphi,0) + \sum\varphi(k)\operatorname{Res}(f,k)$$
where $\gamma$ is a simple positively oriented close curve and the sum extends over the values of $k\in\mathbb{Z}$ contained in the interior of $\gamma$. Now the standard form of the theorem would be:
$$\frac{1}{2\pi i} \int_\gamma f\cdot\varphi \, dz = \sum \operatorname{Res} (f\cdot\varphi,k)$$
So for some reason for $k\neq0$ it holds that $\operatorname{Res}(\varphi f,k) = \varphi(k) \operatorname{Res} (f,k)$, why is that?
Is it more generally true that if $f,g$ are functions such that $z_0$ is a singularity of $f$ but not of $g$ then $\operatorname{Res}(f\cdot g,z_0) = g (z_0) \cdot \operatorname{Res} (f,z_0)$. Is it maybe necessary to assume that $z_0$ is not a zero of $g$ for this to be true?
Help would be appreciated.
 A: 
So for some reason for $k\neq0$ it holds that $\operatorname{Res}\left(\varphi f,k\right)=\varphi\left(k\right)\mbox{Res}\left(f,k\right)$, why is that?

That is because $\varphi$ is holomorphic in $k \neq 0$, and $f$ has a simple pole in $k$.
So we can write $f(z) = (z-k)^{-1}\cdot h(z)$ with $h$ holomorphic and nonzero in a neighbourhood of $k$, and $\operatorname{Res} \left(f;k\right) = h(k)$.
Multiplying that with $\varphi$ gives
$$\varphi(z)f(z) = (z-k)^{-1}\left(\varphi(z)h(z)\right),$$
and if $\varphi(k) = 0$ (our particular $\varphi$ of course has no zeros), then the singularity of $\varphi\cdot f$ in $k$ is removable, hence the residue is $0 = \varphi(k)\cdot h(k)$, making it right, and if $\varphi(k) \neq 0$, the residue in $k$ is (also) $\varphi(k)\cdot h(k)$.
This simple formula, however, holds only for simple poles [it may accidentally happen to coincide with the residue also in other cases, but that's coincidence then].
If we look at the Laurent expansion around a singularity, when the singularity is a simple pole, only the coefficient of $(z-\zeta)^{-1}$ of the singular factor and the constant coefficient of the holomorphic factor contribute.
If the singularity is a pole of higher order, or an essential singularity, all pairs of coefficients whose exponents sum to $-1$ contribute, and these are then more than one pair.
A: If $g$ is holomorphic at some point $z_0$ and $f$ has a simple pole at $z_0$ then $\text{Res}_{z_0}(gf) = g(z_0)\text{Res}_{z_0}(f)$. This is easy to see by looking at the Laurent expansions.
It is not true if $f$ has a pole of higher degree, for instance $1/z = z \times 1/z^2$ has nonvanishing residue at $0$ but $1/z^2$ has vanishing residue. There are also examples where $g$ is nonvanishing, for instance $(1+z)/z^2 = $ has nonvanishing residue, but $1/z^2$ has vanishing residue, even though $1+z$ does not vanish at $0$.
