first, we need to calculate the molar mass of the whole compound by adding the masses of each atom from the periodic table.
Mg= 24.3 g/mol
Br= 80.0 g/mol
molar mass MgBr2= 24.3 + 2 x 80.0= 184.3 g/mol
to find the percent of magnesium doing "parts over the whole"
the mass of magnesium over the total mass. then times 100 because it is a percentage value
24.3/184.3x 100= 13.2%