  We compute the level density of a two--component Fermi gas as a function of
the number of particles, angular momentum and excitation energy. The result
includes smooth low--energy corrections to the leading Bethe term (connected to
a generalization of the partition problem and Hardy--Ramanujan formula) plus
oscillatory corrections that describe shell effects. When applied to nuclear
level densities, the theory provides a unified formulation valid from
low--lying states up to levels entering the continuum. The comparison with
experimental data from neutron resonances gives excellent results.
