How many spectral lines are emitted by atomic hydrogen excited to the n-th energy level? This is a question from Irodov's Problems in General Physics.
The Rydberg formula for calculating the wave number of a spectral line is:
$$
n = R(1/n_f^2-i/n_i^2)\,.
$$
where $n_f$ and $n_i$ represent the final and initial states of the electron respectively, and $R$ is the Rydberg constant.
So for a given value of $n_f$ and a given value of $n_i$, you get one particular spectral line. Change $n_i$ or $n_f$ (or both) and you get a different spectral line.
In the above problem, $n_f$ and $n_i$ can have any integral value from 1 to $n$. The number of spectral lines is simply the number of ways in which you can "choose" two distinct integers from 1 to $n$. That would be $^nC_2$.
However, what if two spectral lines have exactly the same wave number? In other words, what if
$$
1/n_1^2-i/n_2^2=1/n_3^2-i/n_4^2\,
$$
where $n_1$, $n_2$, $n_3$, $n_4$ are distinct integers from 1 to n? In this situation, the two spectral lines would "overlap", and it makes no sense to count them twice when they are actually just the same line. So, shouldn't the actual answer be less than $^nC_2$?
 A: First the formula is wrong. It should be:
$$\tilde \nu = \dfrac{1}{\lambda} = R \left(\dfrac{1}{n_f^2}-\dfrac{1}{n_i^2}\right)$$
where $\tilde \nu$ is the wavenumber of the line, R is the Rydberg constant. Both $n_f$ and $n_i$ are positive integers such that $n_f < n_i$.
The OP asked: However, what if two spectral lines have exactly the same wave number? 
If two spectral lines overlap, then they overlap. There are still two lines since the transitions are between different states. In real spectrometers the overlap would be mostly because of the resolving power of the spectrometer rather than two lines having exactly the same energy. 
I had doubted that two different lines could have the exactly the same energy, but I was wrong. I asked the question  on the Math forum,  and user Hw Chu analyzed the number theory. It turns out that among other solutions:
$$\dfrac{1}{5^2}-\dfrac{1}{7^2} = \dfrac{1}{7^2}-\dfrac{1}{35^2}$$
Hw Chu also named the sets of integers that satisfy the conditions as "Rydberg quadruples" which seems like a very nice name. 
Now I'll speculate again and guess that there is no nice way to calculate the number of different energies of spectral lines given some upper limit of $n_i$ since there is trial and error in finding the Rydberg quadruples.
