Diatomic means the molecules of the gas are made up of two atoms.
So divide the given mass of the molecule by two to get the mass of single atom of which the molecule is made up of.
38/2 = 19 g/mol.
Fluorine atoms have molar mass of 19 g/mol. So, the formula will be F2.