  We present a novel algorithm to compute the density of states, which is
proven to converge to the correct result. The algorithm is very general and can
be applied to a wide range of models, in the frameworks of Statistical
Mechanics and Lattice Gauge Theory. All the thermal or quantum expectation
values can then be obtained by a simple integration of the density of states.
As an application, a numerical study of 4d U(1) compact lattice gauge theory is
presented.
