Step-by-step explanation:
Atomic number of magnesium is 12 and its electronic configuration is 2, 8, 2. So, to acquire stability it loses 2 valence electrons and hence forms
ion.
Whereas atomic number of fluorine is 9 and its electronic distribution is 2, 7. And, to attain stability its needs to gain one electron and hence then it forms
ion.
Therefore, when both magnesium and fluorine chemically combine together then magnesium atom will donate its 2 valence electrons to the fluorine atom.
Hence, they will tend to form magnesium fluoride, that is,
.