The number of ways to arrange n books $= n!$
the number of ways to arrange books in which two books are always together $=(n-1)! \times 2!$
the number of ways to arrange books in which two books are not together $=n!- (n-1)!\times 2!$
by simplification we get $(n-2)\times (n-1)!$