As always we assume an #100*g# mass of stuff, and work out the atomic composition......
#"Moles of barium"=(78.3*g)/(137.3*g*mol^-1)=0.570*mol#
#"Moles of fluorine"=(21.7*g)/(19.00*g*mol^-1)=1.140*mol#
You note that I divided thru by the ATOMIC mass.......
And we simply divide thru by the element present in LEAST molar quantity (barium) to get ........
#BaF_2#...........this is an ionic compound that would be formulated as same. If we do this for an organic formula, we need a molecular mass BEFORE we deduce the molecular formula......
#"molecular formula"=nxx"empirical formula"#............