I'm assuming the order of the books on each shelf is important.

If we have n books on a single shelf, there are n! ways to arrange the books. If we require n > 0, the Exponential Generating Function (EGF) of n! is

For books on two shelves with at least one book on each shelf, the EGF is then

The coefficient of in the above series is

.