In quantum mechanics, for systems where the total number of particles may not be preserved, the number operator is the observable that counts the number of particles.
The number operator acts on Fock space. Given a Fock statecomposed of single-particle basis states :
Bruus, Henrik, Flensberg, Karsten. (2004). Many-body Quantum Theory in Condensed Matter Physics: An Introduction. Oxford University Press. ISBN 0-19-856633-6.