There are 7 ways to choose the calculus textbook at one end, then 6 ways to choose the calculus textbook at the other end. Then there are 9 ways to choose the second textbook, 8 ways to choose the third textbook, and so on. But then there are 4 ways to choose the number theory textbook, so there are 7*6*9!*4 = 60963840 ways that work.