Let's say we have the empirical formula CH4, which has the molar mass of 16.04 grams, and our molecular mass is 48.12.
We then have to divide our molecular mass by our empirical mass. 48.12/16.04 = 3
So my multiply CH4 by a factor of 3, to get out the molecular formula C3H12