You're going from grams to atoms, meaning you're going to have to first convert to an appropriate unit before using Avagadro's number.

If you have 24 g of Mg, and you want to go to atoms, what should you do? You cannot go directly from grams to atoms--there is no conversion factor connecting the two.

Our only option if from grams to ___? Then, you can go from that to atoms. What's the missing link here? We're going from a large unit of measure to a very small unit of measure. When you go from big to small, in terms of units, what algebraic operation is in effect? Multiply? Divide?

Think of a more common example. How do you go from days (big unit) to seconds (small unit)?

Unit conversions from mass to atoms **always** involves a fundamental constant (Avagadro's number).