The formula for a compound tells you how many atoms of each element are in the compound.
For example: There are 2 atoms of phosphorus and 5 atoms of oxygen in each molecule of diphosphorus pentaoxide (P205).
When a formula includes parentheses, the subscript after the parentheses distributes to each element within the parentheses.
For example: Each formula unit of Mg(OH)2 contains 1 atom of magnesium, 2 atoms of oxygen, and 2 atoms of hydrogen.
image version of the lecture