Here's how to determine the formula:
* Magnesium (Mg) is in group 2 of the periodic table, meaning it has a +2 charge as a cation (Mg²⁺).
* Nitrogen (N) is in group 15 of the periodic table, meaning it has a -3 charge as an anion (N³⁻).
To balance the charges, we need three magnesium ions (3 x +2 = +6) and two nitrogen ions (2 x -3 = -6). This gives us the formula Mg₃N₂.