The chemical formula of a compound shows how many of each type of atom join together to make the units that make the compound up.
For example, in iron sulfide every iron (Fe) atom is joined to one sulfur (S) atom, so we show its formula as FeS. In sodium oxide, there are two sodium Na) atoms for every oxygen atom, so we show its formula as Na2O. Notice that the '2' is written as a subscript, so Na2O would be wrong.
The diagram to the right shows that one carbon (C) atom and two oxygen
(O) atoms combine to make up a unit of carbon dioxide. Its chemical formula
should therefore be written as CO2.
Sometimes you see more complex formulae such as Na2SO4 and Fe(OH)3.
A unit of Na2SO4 contains two sodium atoms, one sulfur atom and four oxygen atoms joined together.
A unit of Fe(OH)3 contains one iron atom, three oxygen atoms and three hydrogen atoms (the brackets show that the '3' applies to both the O and the H: the H is the symbol for hydrogen).