So here is the method I learned years ago without memorizing an awkward formula. The concept is to reduce the molecular formula to a hydrocarbon and compare it to the most saturated hydrocarbon bearing the same number of carbon atoms. Consider the infamous free-base, hydroxychloroquine, $\ce{C18H26ClN3O}$.<br><br> <img src="https://i.sstatic.net/uuw2y.jpg" height="200"> <br><br> The following atom replacements may be done in any order. Ignore divalent atoms (O,S). The formula is now $\ce{C18H26ClN3}$. Replace all halogens with an equal number of hydrogens ---> $\ce{C18H27N3}$. Substitute CH for each nitrogen or trivalent atom ---> $\ce{C21H30}$. The most saturated $\ce{C21}$ hydrocarbon is $\ce{C21H44}$. Now do the math. $\ce{C21H44}$ - $\ce{C21H30}$ = $\ce{H14}$. Now divide 14 by 2. The Degree of Unsaturation is 7. QED