We start with the ideal gas law.
\(\displaystyle PV = NkT\)
We will rearrange the equation so that we get \(\displaystyle \frac{\text{molecules}}{\text{volume}}\).
\(\displaystyle \frac{N}{V} = \frac{P}{kT}\)
At \(\displaystyle \text{STP}\), the pressure is \(\displaystyle 101325 \ \text{Pa}\) and the temperature is \(\displaystyle 273.15 \ \text{K}\), and \(\displaystyle k\) is just the \(\displaystyle \text{Boltzmann}\) constant.
Then,
\(\displaystyle \frac{N}{V} = \frac{101325 \ \text{Pa}}{1.38 \times 10^{-23} \ \text{J/K}(273.15 \ \text{K})} = \frac{101325 \ \text{Pa}}{1.38 \times 10^{-23} \ \text{J}(273.15)}\)
Our goal at this point is to write the units in terms of \(\displaystyle \text{m}^3, \text{cm}^3, \text{or} \ \text{mm}^3\).
\(\displaystyle \text{Pa} \rightarrow \text{N/}\text{m}^2\)
\(\displaystyle \text{J} \rightarrow \text{Nm}\)
This gives:
\(\displaystyle \frac{N}{V} = \frac{101325}{1.38 \times 10^{-23} \ \text{m}^3(273.15)} = 2.69 \times 10^{25} \ \text{molecules/}\text{m}^3\)
Let us assume that the volume of one molecule is \(\displaystyle a^3\) and it is a cube. Then, the volume of all molecules is:
\(\displaystyle V = Na^3\)
Then, the average distance is the length of one side of one cube. That is:
\(\displaystyle a = \sqrt[3]{\frac{V}{N}} = \sqrt[3]{\frac{1}{\frac{N}{V}}} = \sqrt[3]{\frac{1}{2.69 \times 10^{25}}} = 3.34 \times 10^{-9} \ \text{m} = \textcolor{blue}{3.34 \times 10^{-7} \ \text{cm}}\)