When electrons de-excite from higher energy level $\left(n_{2}\right)$ to lower energy level $\left(n_{1}\right)$ in atomic sample, then number of spectral line observed in the spectrum $$ =\frac{\left(\mathrm{n}_{2}-\mathrm{n}_{1}\right)\left(\mathrm{n}_{2}-\mathrm{n}_{1}+1\right)}{2} $$
According to Quora, this is derived from permatuation & combination. Can you please help me the derivation from permatuation & combination
Let $k=n_2-n_1$. the number of states between (and including) energy levels $n_1$ and $n_2$ is $k+1$. thus the number of spectral lines is the number of ways of choosing 2 states from the $k+1$ states, which is $${k+1\choose 2}=\frac{(n_2-n_1+1)(n_2-n_1)}{2}$$