To write the formula first look at the name of the compound.
For example magnesium chloride.
Magnesium chloride has 2 ions - the magnesium ion and the chloride ion.
Determine the oxidation numbers (charges) on these 2 ions.
Magnesium = Mg 2+
Chloride = Cl -
The oxidation number (charge) of a compound must be neutral. To determine the oxidation number of a compound add
the oxidation numbers of the ions.
oxidation number of compound = (# of ions)(oxidation #) + (# of ions)(oxidation #)
So if the formula of magnesium chloride was MgCl the oxidation number of the compound would be:
=(1)(+2) + (1)(-1)
= +2 + -1
therefore the formula cannot be MgCl
If the formula of magnesium chloride was MgCl2 the oxidation number of the compound would be:
=(1)(+2) + (2)(-1)
= +2 + -2
therefore the correct formula for magnesium chloride is
An easy way to determine formulas is to switch the oxidation numbers. Remember a "1" is never written in the formula.