Find number of ways to arrange $1$ to $n$ in a line so that no two consecutive numbers are adjacent.
I know this is https://oeis.org/A002464 !!
I tried it with inclusion exclusion and got the number of ways as
$n!-\sum_{k=1}^{n-1}$$\left((-1)^k(n-k)!\sum_{r=1}^{k}2^r\binom{n-k}{r}\binom{k-1}{r-1}\right)$
I also tried it with generating function my approach is almost same as this
Flajolet and Sedgewick generating function for Hertzsprung Problem
I want to know how to establish following recurrence:
Let $a_n$ be the required number of ways. Then
$a_n=(n+1)a_{n-1}-(n-2)a_{n-2}-(n-5)a_{n-3}+(n-3)a_{n-4}\forall n\ge 4;a_0=1,a_1=1,a_2=0,a_3=0.$
Same problem here: Special permutations of $\{1,2,3,\ldots,n\}$
Similar problems but simpler than the current one:
How many permutations of $\{1,2,3,...,n\}$ there are with no 2 consecutive numbers?
Show number of permutations on $[n]$ where $i$ is not followed by $i+1$ is $D_n + D_{n-1}$