2.
Find the number of moles of carbon dioxide. (You have mass and relative mass)
Write the equation.
You'll find that one mole of CO2 is given off when 1 mole of Mg^2+ reacts.
So, you know the amount of Mg^2+ present.
Find the mass of that amount.
Then percentage purity is