# Books on shelves [duplicate]

How many ways you can use to put N books on H shelves, but the shelf's must contain not more than X books? I would like to solve it by composition (number theory)..but nothing.. Please help me, thanks a lot.

## marked as duplicate by Quixotic, Bill Cook, Asaf Karagila♦, J. M. is a poor mathematician, Zev ChonolesNov 10 '11 at 3:30

Let $a_i$ be the number of books place on shelf $i$, $i=1,2,\dots,H$. Then you want the number of solutions of $$a_1+a_2+\cdots+a_H=N$$ with each $a_i$ an integer satisfying $0\le a_i\le X$. That question has come up multiple times on this site. Let's both try searching the site to see if we can find one of those previous appearances.