Hello, Mary,
This is where the concept of the mole comes in handy. One mole is 6.022x1023 particles (atoms, molecules, paper clips, etc.) of anything. We want atoms. To find atoms we need to use the molar mass of Mg. Molar mass is the number of grams of that element or compond it takes to reach one mole of that item. The mole is tied to the atomic mass of the element or compound. The atomic mass of Mg is 24.3 AMU (atomic mass units). That also means that 24.3 grams of Mg contains 1 mole of atoms. That makes this a handy conversion factor:
(24.3g Mg/1 mole Mg), or 24.3 g/mole
------
Now we can answer the question. We are given 29.8 grams of magnesium. To convert this to atoms of magnesium, divide the grams Mg by the molar mass of Mg. Note the units and how grams cancel, leaving just atoms.
(29.8 grams Mg)/(24.3g Mg/1 mole Mg) = 1.23 moles Mg
Now multiply 1.23 moles Mg times 6.022x1023 atoms/mole to find atoms.
7.38x1023 atoms of Mg
Bob