I'm self-studying the text Harmonic Analysis: From Fourier to Wavelets and on page 10 the formula for calculating Fourier coefficients $$ \hat{f}(n) = a_{n} $$ is derived. The part that I'm confused at is that it's shown that the following equality holds: $$ \frac{1}{2\pi} \int_{-\pi}^{\pi} e^{in\theta}e^{-ik\theta} d\theta = \delta_{n, k} $$ where $$ \delta_{n,k} = 1, \space \text{if} \space k = n \space \text{and} \space 0, \space \text{if} \space k \neq n $$
I understand why it's $1 $ when $n = k$ as it's simply $$ \frac{1}{2\pi} \int_{-\pi}^{\pi} e^{0} d\theta \implies \frac{1}{2\pi} (\pi - (-\pi)) \implies 1 $$ but I can't seem to catch why it's zero when $n $ and $k$ are not equal. When I evaluate the integral, I get the following:
$$ \frac{1}{2\pi}\int_{-\pi}^{\pi} e^{i(n-k)\theta} d\theta \implies \frac{1}{2\pi i(n-k)} e^{i (n-k) (\pi - (-\pi))} \implies \frac{1}{2 \pi i(n-k)} e^{2 \pi i (n-k)} \neq 0 $$
Could someone please give me a hint on what I'm doing wrong or what I'm misunderstanding?
Firstly, there is a careless calculation in the last displayed formula. $$\frac{1}{2\pi}\int_{-\pi}^{\pi} e^{i(n-k)\theta} d\theta = \frac{1}{2\pi i(n-k)} e^{i (n-k) \pi}-\frac{1}{2\pi i(n-k)} e^{i (n-k) (-\pi)}$$
Secondly, we usually consider $n$ and $k$ are integers. In this case, it's zero. If not, let $n=1$, $k=\frac12$. You will find it's not zero.