I found a formula for the degree of unsaturation (DU) in Clayden’s Organic Chemistry. It explains, simply, the unsaturation with the difference in H atoms. Then I stumbled upon the general formulageneral formula:
$$DU=1+\frac12\sum n_i\left(v_i-2\right)$$
https://en.wikipedia.org/wiki/Degree_of_unsaturation$n_i$ is the number of atoms with valence $v_i$.
Can someone explain from where this equation was derived? And how come the valence term was introduced?