# How does this step involving the Dirac delta work?

I'm learning the course of Digital Signal Processing and there is a formula what is not totally clear to me. \begin{align*} w[n]\sum_{k=0}^{M-1} \exp\left(-\frac{j2\pi kn}{M}\right) &= w[n] \frac{1-\exp(-j2\pi n)}{1-\exp(-j2\pi n/M)} \\ &= w[n] \begin{cases} M & \text{if } n = kM, \\ 0 & \text{otherwise} \end{cases} \\ &= w[n] \sum_{k=-\infty}^\infty \delta[n-kM] \end{align*} I don't understand how we go between the second and the third member. Please could somebody explain it?

If $n=kM$, then both the numerator and denominator are zero, implying you need to take a limit. Using l'Hopital's rule, you immediately get $M$. If $n$ is an integer and not a multiple of $M$, then only the numerator is zero.
• Thanks a lot for your response but I didn't understand why if n=kM the numerator is zero...in this case, I obtain $e^{-j2pikM}$ and it's not equal to one ... – lauren Jan 5 '15 at 19:48
• @lauren: the term in the exponential is $-j 2\pi k M$, where $k M$ is an integer. Are you aware that $e^{-j2\pi }=1$? – Alex R. Jan 5 '15 at 19:54