Ideal gas equation is PV = nRT
where P = pressure, V = volume, n = number of moles of gas, R = gas constant = 0.0821 L·atm/mol·K, and T = absolute temperature (in Kelvin)
To find the density of the gas, you need to know the mass of the gas and the volume.
V = nRT/P
The number of moles is the mass (m) of the gas divided by its molecular mass:
n = m/MM
Substitute this mass value into the volume equation in place of n
V = mRT/MM·P
Density (ρ) is mass per volume. Divide both sides by m:
V/m = RT/MM·P
m/V = MM·P/RT
ρ = MM·P/RT