GATE Computer ScienceVery hardGATE CS (PYQ pattern)

In how many permutations of 1, 2, …, 8 does NO entry i appear immediately followed by i + 1 (so 1 2, 2 3, …, 7 8 never occur as consecutive neighbours)?

  1. A. 14833
  2. B. 5040
  3. C. 16083
  4. D. 16687

Correct answer: D. 16687

Inclusion-exclusion over forced successions gives Σ(−1)ᵏ C(7,k)(8 − k)! = 16687, which equals D₈ + D₇ = 14833 + 1854. Subtracting only the single-succession cases gives 40320 − 7·5040 = 5040, the trap.

More Discrete Mathematics questions

Exams that ask this topic