Recently, I found that when electrons in an atomic sample de-excite from a higher energy level ($n_2$) to a lower energy level ($n_1$), the number of spectral lines observed in the spectrum is
$$\frac{(n_2 - n_1)(n_2 - n_1 + 1)}{2}$$
Can anyone please tell me how to derive this?