Compressibility factor of gases is a thermodynamic property which is used to modify the ideal gas equation for real gases.
For Ideal gases, Ideal gas equation states,
PV = nRT
This equation can be modified for real gases, to be expressed as,
PV = ZnRT, here Z is the compressibility factor for the given gas.
The compressibility of a gas depends on the particular gas as well as temperature and pressure conditions. You can use different equations of state for calculating the compressibility factor of a gas as a function of temperature and pressure.
These equations of state have provided formula to calculate Z factor. The constant parameters used in these equations are empirically determined for a gas. For example, compressibility factor for natural gases.
Compressibility is a function of reduced Temperature and Pressure
You can use compressibility charts available from literature to calculate the Z factor for different gases at given temperature and pressure conditions. You can calculate the Z factor as a function of the reduced temperature and reduced pressured, using these charts.
Reduced temperature, Tr = T / Tc
Reduced pressure, Pr = P / Pc
where Tc and Pc are critical temperature and pressure values respectively.
Some correlations such as Pitzer correlations, use the gas reduced properties such as reduced temperature and reduced pressure to approximately calculate the Z factor. You can also use EnggCyclopedia's Z factor calculator to calculate the compressibility factor based on such correlations.