To solve this problem we will use the concept given on the calculation of volume in a sphere (for which we will apply the approximation of the earth) as well as the relationship between density, mass and volume, like this:
Mass of atmosphere
Density of Atmosphere
Now the Volume would be,
The volume geometrically can be expressed as
Atmosphere is spread all over earth therefore the sphere surface area (of earth)
Diameter of the earth
Now calculating the height:
This value is estimated since the approximation of a sphere to the earth was made, and this, as we well know, does not comply with that approximation in detail.
We must add that the atmosphere decreases with the height so the value of 31 km is given for the first layer of the atmosphere.