In classical mechanics, the state of an ideal gas of energy U, volume V and with N particles, each particle having mass m, is represented by specifying the momentum vector p and the position vector x for each particle. This can be thought of as specifying a point in a 6N-dimensional phase space, where each of the axes corresponds to one of the momentum or position coordinates of one of the particles. The set of points in phase space that the gas could occupy is specified by the constraint that the gas will have a particular energy:
and be contained inside of the volume V (lets say V is a cube of side X' so that ):
for  and 
The first constraint defines the surface of a 3N-dimensional hypersphere of radius (2mU) and the second is a 3N-dimensional hypercube of volume V. These combine to form a 6N-dimensional hypercylinder.  Just as the area of the wall of a cylinder is the circumference of the base times the height, so the area φ of the wall of this hypercylinder is:
The entropy is proportional to the logarithm of the number of states that the gas could have while satisfying these constraints. In classical physics, the number of states is infinitely large, but according to quantum mechanics it is finite. Before the advent of quantum mechanics, this infinity was regularized by making phase space discrete. Phase space was divided up in blocks of volume h. The constant h thus appeared as a result of a mathematical trick and thought to have no physical significance. However, using quantum mechanics one recovers the same formalism in the semi-classical limit, but now with h being the Planck constant. One can qualitatively see this from Heisenbergs uncertainty principle; a volume in N phase space smaller than h (h' is the Planck constant) cannot be specified.
To compute the number of states we must compute the volume in phase space in which the system can be found and divide that by h. This leads us to another problem: The volume seems to approach zero, as the region in phase space in which the system can be is an area of zero thickness. This problem is an artifact of having specified the energy U with infinite accuracy. In a generic system without symmetries, a full quantum treatment would yield a discrete non-degenerate set of energy eigenstates. An exact specification of the energy would then fix the precise state the system is in, so the number of states available to the system would be one, the entropy would thus be zero.
When we specify the internal energy to be U, what we really mean is that the total energy of the gas lies somewhere in an interval of length  around U. Here  is taken to be very small, it turns out that the entropy doesnt depend strongly on the choice of  for large N. This means that the above "area" φ' must be extended to a shell of a thickness equal to an uncertainty in momentum , so the entropy is given by:
where the constant of proportionality is k, the Boltzmann constant. Using Stirlings approximation for the Gamma function which omits terms of less than order N, the entropy for large N' becomes:
This quantity is not extensive as can be seen by considering two identical volumes with the same particle number and the same energy. Suppose the two volumes are separated by a barrier in the beginning. Removing or reinserting the wall is reversible, but the entropy increases when the barrier is removed by the amount
which is in contradiction to thermodynamics if you re-insert the barrier. This is the Gibbs paradox.
The paradox is resolved by postulating that the gas particles are in fact indistinguishable. This means that all states that differ only by a permutation of particles should be considered as the same state. For example, if we have a 2-particle gas and we specify AB as a state of the gas where the first particle (A) has momentum p and the second particle (B) has momentum p, then this state as well as the BA state where the B particle has momentum p and the A particle has momentum p should be counted as the same state.
For an N-particle gas, there are N! states which are identical in this sense, if one assumes that each particle is in a different single particle state. One can safely make this assumption provided the gas isnt at an extremely high density. Under normal conditions, one can thus calculate the volume of phase space occupied by the gas, by dividing Equation 1 by N!. Using the Stirling approximation again for large N, ln(N!) ≈ N ln(N) − N, the entropy for large N' is:
which can be easily shown to be extensive. This is the Sackur–Tetrode equation.