calculate $\oint_{|z|=1} \left(\frac{z}{z-a}\right)^n \, dz$ calculate $\oint_{|z|=1}\left(\frac{z}{z-a}\right)^{n}$
whereas a is different from 1, and n is integer.
My try:
\begin{align}
& \oint_{|z|=1}\left(\frac{z}{z-a}\right)^n \, dz\\[6pt]
& \oint_{|z|=1}\frac{z^n \, dz}{\sum_{k=0}^n z^k(-a)^{n-k}}\\[6pt]
& \oint_{|z|=1}\sum_{k=0}^n\frac{z^n \, dz}{z^k(-a)^{n-k}}\\[6pt]
& \oint_{|z|=1}\sum_{k=0}^n\frac{z^{n-k} \, dz}{(-a)^{n-k}}
\end{align}
I forgot here to write the binomial but it won't change the answer.
no singularities therefore it's $0.$
if $n$ is smaller than $0$:
\begin{align}
& \oint_{|z|=1}\left(\frac{z-a}{z}\right)^n \, dz\\[6pt]
& \oint_{|z|=1}\frac{\sum_{k=0}^n \binom n k z^k(-a)^{n-k} \, dz}{z^n}\\[6pt]
& \oint_{|z|=1}\sum_{k=0}^n
\binom n k \frac{z^{k}(-a)^{n-k}dz}{z^{n}}\\[6pt]
& \oint_{|z|=1}\sum_{k=0}^n \binom n k z^{k-n}(-a)^{n-k}\, dz
\end{align}
so if so we look $k-n=-1$
$k=n-1$
which is exactly $-na$
therefore the value of the integral is $-2n \pi i a$
 A: You can't just pull the sum out of the denominator. You need Cauchy's generalized integral formula for $n\geq0$. If $a$ is in the interior of $C$, where $C$ is a circle, then
$$f^{(k)}(a)=\frac{k!}{2\pi\mathrm i}\oint_C\frac{f(z)}{(z-a)^{k+1}}\mathrm dz.$$
Here, $k=n-1$ and $f(z)=z^n$. So the integral is $\frac{2\pi\mathrm i}{(n-1)!}n!a=2\pi\mathrm i na$. This is for $n\geq0$. For $n<0$ what you did looks good (you're not pulling a sum out of the denominator there). But you should be using $-n$ or $\vert n\vert$ when flipping denominator and numerator. So the solution is $2\pi\mathrm i n a$ again.
A: If $|a|>1$, and $n$ is a non-negative integer, then the function $f(z)=\left(\frac{z}{z-a}\right)^n$ is analytic on the disk $|z|\le 1$ and Cauchy Integral Theorem guarantees that
$$\oint_{|z|=1}\frac{z^n}{(z-a)^n}\,dz=0$$

METHODOLOGY $1$:  For $|a|<1$
For $n\ge 0$, we can write
$$\left(\frac{z}{z-a}\right)^n=\left(1+\frac{a}{z-a}\right)^n=\sum_{k=0}^n \binom{n}{k}a^k(z-a)^{-k}$$
The coefficient on the $\frac{1}{z-a}$ term is $na$.  So from the Residue Theorem, we have for $|a|<1$
$$\oint_{|z|=1}\left(\frac{z}{z-a}\right)^ n\,dz=2\pi i na$$

For $n<0$, we can write
$$\left(\frac{z}{z-a}\right)^n=\left(1+\frac{a}{z}\right)^{|n|}=\sum_{k=0}^{|n|} \binom{|n|}{k}(-a)^k(z)^{-k}$$
The coefficient on the $\frac{1}{z}$ term is $-|n|a$.  So from the Residue Theorem, we have
$$\oint_{|z|=1}\left(\frac{z}{z-a}\right)^ n\,dz=-2\pi i |n|a=2\pi i n a$$


METHODOLOGY $2$:For $|a|<1$
If $n$ is a negative integer, then the function $f(z)=\left(\frac{z}{z-a}\right)^n$ has a pole of order $|n|$ at $z=0$.  Hence, application of the residue theorem reveals
$$\begin{align}
\oint_{|z|=1}\left(\frac{z}{z-a}\right)^ n\,dz&=\oint_{|z|=1}\left(\frac{z-a}{z}\right)^{|n|}\,dz\\\\
&=2\pi i \frac1{(|n|-1)!}\lim_{z\to  0}\frac{d^{|n|-1}}{dz^{|n|-1}}(z-a)^{|n|}\\\\
&=-2\pi i|n|a\\\\
&=2\pi i na
\end{align}$$

If $|a|<1$, and $n$ is a non-negative integer, then the function $f(z)=\left(\frac{z}{z-a}\right)^n$ has a pole of order $n$ at $z=a$ and application of the residue theorem reveals
$$\begin{align}
\oint_{|z|=1}\left(\frac{z}{z-a}\right)^ n\,dz&=2\pi i \frac1{(n-1)!}\lim_{z\to  a}\frac{d^{n-1}}{dz^{n-1}}z^{|n|}\\\\
&=2\pi i n a
\end{align}$$
