Assume that you have 100 g of formaldehyde.
Then you have 40.0 g of #"C"#, 6.7 g of #"H"#, and 53.3 g of #"O"#.
Our job is to calculate the ratio of the moles of each element.
#"Moles of C" =40.0 color(red)(cancel(color(black)("g C"))) × "1 mol C"/(12.01 color(red)(cancel(color(black)("g C")))) = "3.331 mol C"#
#"Moles of H" = 6.7 color(red)(cancel(color(black)("g H"))) × "1 mol H"/(1.008color(red)(cancel(color(black)("g H")))) = "6.65 mol H"#
#"Moles of O" = 53.3 color(red)(cancel(color(black)("g O"))) × "1 mol O"/(16.00 color(red)(cancel(color(black)("g O")))) = "3.331 mol O"#
To get the molar ratio, we divide each number of moles by the smallest
number (#3.331#).
From here on, I like to summarize the calculations in a table.
#"Element"color(white)(X) "Mass/g"color(white)(X) "Moles"color(white)(X) "Ratio" color(white)(X)"Integers"#
#stackrel(—————————————————-—)(color(white)(l)"C" color(white)(XXXX)40.0 color(white)(Xlll)3.331 color(white)(Xll)1 color(white)(XXXlll)1)#
#color(white)(X)"H" color(white)(XXXXl)6.7 color(white)(XXl)6.65 color(white)(XXl)2.00 color(white)(XXl)2#
#color(white)(X)"O" color(white)(XXXll)53.3 color(white)(XXl)3.331 color(white)(Xll)1.00 color(white)(XXl)1#
The ratio comes out as #"C:H:O"=1:2:1#.
Thus, the empirical formula is #"CH"_2"O"#.