The number of moles in a substance indicates the amount of the substance that contains the same number of particles as 12 g of the Carbon-12 isotope [or equivalent to 6.02 × 10²³ (which is used as a standard in the world of moles).
Now,
if 6.02 × 10²³ atoms are found in 1 mole of Mg
then let 6.98 × 10²⁴ atoms are found in x
⇒ x = (6.98 × 10²⁴) ÷ (6.02 × 10²³)
= 11.595 mol
Also,
Mass = Mole × Molar Mass
∴ Mass of Mg = 11.595 mol × 24 g / mol
= 278.27 g
The mass of a sample of 6.98 × 10²⁴ atoms of magnesium (Mg) would contains 278.27 g