Of course, we know that the molecular formula of acetic acid is H_3C-CO_2H. Now we also know that the empirical formula is the simplest, whole number ratio that defines constituent atoms in a species, and thus the molecular formula is a whole number multiple of the empirical formula.
And given H_3C-CO_2H, we divide thru by 2 to give an empirical formula of CH_2O. Most of the time we must assess the empirical formula FIRST by some means, and then measure the molecular mass by some means, and THEN derive the molecular formula. Here, we have done it in a different order.
The molecular formula of formaldehyde is also CH_2O.