Answer : Note : The formula give in the question needs to be corrected , the formula of two chlorine atoms for every magnesium atom in the compound is
which is Magnesium Chloride.
Explanation : To write the formula of the compound we need to know the charge of the atoms or elements involved in the formula.
Charge of Mg is +2 and charge of Cl is -1 , to write the formula of the compound we always criss cross the charges. And also when we write the formula the total (or net) charge of the compound should be 0. Charge of Mg is +2 so to get the total(net) charge as 0 we need two Cl atoms with each -1 charge.
Mg = +2 , Cl = -1 , Cl = -1
2 Cl = -1 + (-1) = -2
Mg = +2 and 2 Cl = -2
+2 -2 = 0

So the formula for Magnesium Chloride is
