Write the formula for magnesium phosphide.
Magnesium phosphide is an ionic compound that contains the ions Mg^{2+} and P^{3-}.
Using charge balance, we determine the number(s) of each type of ion.
3(2+) + 2(3-) = 0
3Mg^{2+} and 2P^{3-} give the formula Mg_3P_2.