How many ways can you arrange 4 different math books and 3 different science books on a shelf?

A) assume 3 different math books as a single book. now, total 1 + 2 + 4 = 7 books no. of ways to arrange 7 books = 7! group of 3 math books can also be arranged by 3! ways. so, total no. of ways = 7! * 3! answer is : 7! * 3! B) now, assume books of each subject as a single book. total no. of books = 3 no. of ways to arrange 3 books = 3! similarly as previous part, physics and chemistry books can be arranged in their group in 2! and 4! ways. total no. of ways = 3! * 3! * 2!* 4!

Question: "In how many ways can 2 different history books, 5 different math books, and 4 different novels be arranged on a shelf if the books of each type must be together?"

In this question, sequence of the books is not important, therefore:

  • For the 2 history books: 2 ways to arrange them (AB and BA), or $2!$
  • For the 5 math books: $5*4*3*2*1 = 5!$ ways to arrange them, or 120
  • For the 4 novels: $4*3*2*1 = $4!$ ways to arrange them, or 24

Think like this:

  • For the history books (assuming we only look at the history books): 2 options for the first slot, and 1 for the last
  • For the math books (again, only look at the math books): 5 options for the first slot, $5-1=4$ for the second slot, $5-2=3$ for the third and so on
  • The same for the novels

We also have three types of books, so, the order of first-to-appear is, by the same logic, 3!

Therefore, in the the end you have $2!*5!*4!*3!=34560$ ways to arrange those books