How to calculate
Start with one plus the carbon count, add half the nitrogen count, and subtract half the hydrogen and halogen count.
Worked example
Use Chemical formula C6H6. The result is ≈ 4.
Input and result notes
Use ordinary closed-shell valences. Rings and double bonds contribute one each. A triple bond contributes two.
OpenStax organic chemistry on degrees of unsaturation