I have been studying quantum mechanics(blackbody radiation basically) and came up with an equation in Planck's derivation(where he had to assume that the oscillators in the cavity walls were limited to energies of $\epsilon_n = nh\nu,\:$ where $n = 0, 1, 2, 3, ...$) that the average energy per standing wave in the cavity is given by $$\bar\epsilon = \frac{h\nu}{e^{h\nu/kT}-1}$$ instead of energy equipartition average of $k_BT$ which Rayleigh and Jeans had used by classical mechanics(Here, $k_B$ is the Boltzmann's constant).
How can we prove this equation of average energy $\:\bar\epsilon\:$ that Planck came up with? How Planck got this relation? The only thing I know is that from Maxwell-Boltzmann's distribution law, the number of oscillators with energy $\:\epsilon_n\:$ is proportional to $exp[-\epsilon_n/k_BT]$.
Thanks in advance for any help