Suppose that I have 6 different books, 2 of which are math books. In how many ways can I stack my 6 books on a shelf if I do not want the math books to be next to each other?
Ways to arrange the math books
1x1xxx 4 ways x 2 =8
1xx1xx 3 ways x2 6
1xxx1x 2 ways x 2 =4
1xxxx1 2 ways
total 20 ways
the other three slots can be arranged amonsth the remaining 4 books in 4 * 3 * 2 *1 = 24 ways for each math book arrangement
20 * 24 = 480 ways