This is a stoichiometry problem, where we have an initial amount of reactant and we need to find out how much of the product will we end up with, in order to do that we need to:
1. Set up the properly balanced equation, which the question already provided us
2 Mg + O2 -> 2 MgO
2. See how many moles of reactant there are in the given amount of grams, 5.85 grams, and the molar mass of the reactant is 32g/mol
32g = 1 mol
5.85g = x moles
x = 0.183 moles of O2 in 5.85 grams
3. Check the molar ratio between the two compounds, for O2 and MgO the molar ratio is 1:2, 1 mol of O2 for every 2 moles of MgO, therefore:
1 O2 = 2 MgO
0.183 O2 = x MgO
x = 2 * 0.183
x = 0.366 moles of MgO
4. Calculate how many grams will be equal to the number of moles that we found out, 0.366 moles and the molar mass of MgO, 40.30g/mol
40.30g = 1 mol
x grams = 0.366 moles
x = 0.366 * 40.30
x = 14.75 grams of MgO are produced from 5.85 grams of O2