The formula would be #Mg_3P_2#. It would be an ionic compound. First of all, we know that it is an ionic compound because one of the elements is a metal. The formula is based on the combination of these ions in the smallest ratio, resulting in a total charge of zero, since all compounds must be electrically neutral. From the periodic table or valence layers of atoms, we can determine that magnesium forms an ion of charge #+2#. In addition, phosphorus forms an ion #-3#. Three ions #Mg^(2+)# and two ions #P^(3-)# give a total of +6 and -6 charges, which gives us the total charge zero. A compound with three magnesium ions and two phosphorus ions would be written #Mg_3P_2#.
