Turn every element into moles by dividing its mass (or its percentage read as a mass out of 100) by its Ar, then divide through by the smallest amount to get the atom ratio; that ratio is the empirical formula. For a molecular formula, scale the whole empirical unit by Mr(empirical unit)Mr(molecule).
Trigger: a compound described by the masses or mass fractions of its elements, or a molecular mass stated as a multiple of the empirical mass.
Instances:
(i) mass data: subtract to recover any missing element, divide each mass by its Ar, then take the simplest ratio (a 2:5 ratio gives Br2O5);
(ii) an awkward ratio such as 1.5:2 is not an error: multiply the whole ratio up to whole numbers (1.5:2=3:4, giving Fe3O4), never round;
(iii) molecular from empirical: find the empirical mass, then multiply every subscript by Mr over that mass (C2F3 has mass 81, the molecule 162, so C4F6);
(iv) if composition is given as fractions and one element's absolute mass is fixed by the chemistry (bromine adds as Br2, two atoms per molecule), read Mr as that element's mass divided by its mass fraction.