Deducing the number of π bonds and rings

The molecular formula of a compound gives important clues to the structure and to the nature of the functional group(s) present in the molecule.
These clues are given by both the number and the types of atoms present.

it is possible to distinguish between saturated functional groups and unsaturated functional groups by calculating the total number of π (pi) bonds and/or rings present in the compound. This number is called the number of double bond equivalents or degrees of unsaturation.

A ring is a "double bond equivalent" because converting a carbon chain into a ring involves removing two hydrogens from non-adjacent carbons. Forming a double bond also involves removing two hydrogens, in this case from adjacent carbons.
 
Thus cyclopentane and pent-2-ene both have the molecular formula C5H10.
An alkane having five carbons would have the formula C5H12. Therefore both cyclopentane and pentene have 1 double bond equivalent (degree of unsaturation).



CH3CH=CHCH2CH3

Most organic compounds contain elements other than hydrogen and carbon, most commonly oxygen, nitrogen or halogen.  To compare their number of hydrogens with the corresponding alkane, it may be necessary to adjust the number of hydrogens in accord with the other elements that are present. 

Oxygen:  Hydrogen number remains the same
Inserting an O between carbons in a chain (such as CH3CH3 to CH3OCH3) or between a C and an H (CH3CH3 goes to CH3CH2OH) does not change the number of hydrogens. Introduction of a C=O double bond has the same effect as introducing a C=C because both result in removal of two hydrogens.
 
Halogen: Add one hydrogen for each halogen that is present
Hydrogen and halogen are both monovalent so halogen simply replaces hydrogen (CH3CH2Cl goes to CH3CH3)
 
Nitrogen:  Subtract one hydrogen for each nitrogen that is present.
Nitrogen is trivalent.  If CH3CH3 goes to CH3CH2NH2, the nitrogen has inserted between carbon and hydrogen, and one extra hydrogen is required at nitrogen.Therefore there is an extra hydrogen present for each nitrogen in the compound.
 
Example: Consider a compound C7H12NClO
 Adjust for oxygen  C7H12NCl
 Adjust for halogen  C7H13N
 Adjust for nitrogen  C7H12
 Corresponding alkane  C7H16
 Number of π bonds and/or rings in C7H12NClO  2