A chemical formula tells us the ratio of atoms in a substance, and chemistry recognizes two important kinds. The empirical formula is the simplest whole-number ratio of atoms of each element in a compound. The molecular formula gives the actual number of atoms of each element in one molecule. For glucose, the molecular formula is $C_6H_{12}O_6$, while the empirical formula is $CH_2O$, because dividing each subscript by six gives the simplest ratio. For many ionic compounds, such as sodium chloride, the formula written is already the empirical formula, since ionic solids do not exist as discrete molecules.
To determine an empirical formula from experimental data, we work from the masses or percentages of each element present. The strategy is always the same: convert the mass of each element