# How many ways are there to distribute M excitations of N identical particles among K=3 quantum harmonic oscillators?

I'm trying to numerically calculate a partition function of N non-interacting but identical particles in a 3D SHO. To do this, I'd like to know the degeneracy of $M$ excitations, $N$ indistinguishable particles, in $K=3$ distinguishable oscillators. In other words, what's the degeneracy of $E = \hbar \omega (M + 1/2)$? I want to capture the Bose statistics and calculate something like a few-particle Bose-Einstein condensate.

For example, if I have two excitations, two particles, and three oscillators, the degeneracy is nine (please correct me if I'm wrong!):

• Both excitations in one oscillator: 3 ways
• One excitation in each of two oscillators: 6 ways

My current approach is to write an algorithm that counts all of these combinations, but I feel like there must be a simpler way.

Alternatively, say we only have one oscillator. How many ways can I distribute M excitations among N identical particles?

Edit: I originally miscounted the degeneracy of my example. I think it's 9, not 6.

-