How many grams of magnesium are required to produce a total of 4.05g of hydrogen

Mg + what acid? HCL?

Mg + 2HCl --> H2 + MgCl2
mols H2 = grams/molar mass
Use the coefficients in the balanced equation to convert mols H2 to mols Mg.
Now use mols Mg and convert to grams. g = mols Mg x atomic mass Mg.