  A functional theory based on single-particle occupation numbers is developed
for pairing. This functional, that generalizes the BCS approach, directly
incorporates corrections due to particle number conservation. The functional is
benchmarked with the pairing Hamiltonian and reproduces perfectly the energy
for any particle number and coupling.
