Start by putting the arrangement of books below on the
shelf so that there are exactly 2 math books between any
two physics books there.
__PMM__PMM__PMM__PMM__MP__
(M stands for a math book and P for a physics book, and the 6 blanks
are gaps or places where we can insert the remaining math books
All 5 physics books, P's, and 8 of the 13 math books, M's are on the
shelf. So we have to insert the remaining 5 math books, M's, into
some of the 6 blanks.
That's the number of partitions of 5 things into 6 blanks,
(which includes putting no M's in some or even
all but 1 space, and all 5 in that space.)
The number of partitions of n indistinguishable things into r places.
[which includes putting 0 in some places, and extreme cases where all n
things are in 1 place.]
is
(n+r-1)C(r-1), where n=5, r=6
(5+6-1)C(6-1) = 10C5 = 252 ways to arrange the books.
Answer: 252
Edwin