Each element has a distinct spectral fingerprint. When an element's gaseous state is heated, it will give off light. When this light is passed through a prism or diffraction grating, bright lines of different colors can be distinguished. Each element is slightly different from other elements. This discovery was the beginning of the study of spectroscopy.
Johannes Rydberg was a Swedish physicist who attempted to find a mathematical relationship between one spectral line and the next of certain elements. He eventually discovered there was an integer relationship between the wavenumbers of successive lines.
His findings were combined with Bohr's model of the atom to give the formula:
1/λ = RZ2(1/n12 - 1/n22)
λ is the wavelength of the photon (wavenumber = 1/wavelength)
R = Rydberg's constant (1.0973731568539(55) x 107 m-1)
Z = atomic number of the atom
n1 and n2 are integers where n2 > n1.
It was later found n2 and n1 were related to the principle quantum number or energy quantum number. This formula works very well for transitions between energy levels of a hydrogen atom with only one electron. For atoms with multiple electrons, this formula begins to break down and give results that are incorrect.