how many permutations of {1,2,...,9} How many permutations of {1,2,…,9} are there such that 1 does not immediately precede 2, 2 does not immediately precede 3, and so forth up to 8 not immediately preceding 9? One obvious example of such a permutation might be 987654321, but there are many others, such as 132465879 or 351724698.
 A: For $\{1,2,3,\dots,n\}$, the numbers are tabulated here, along with lots of information, formulas, references, links, and whatnot. For $n=9$, it says 148329. 
A: Call a permutation of your form "good".
Consider the general problem, with $n$ elements. Let $A_n$ be the number of good permutations (so you are after $A_9$).  
The last number, $n$, is special as it can precede anything.  In particular, there are two ways to make a good permutation.
I.  Take a good permutation on $n-1$ letters and place the $n$ in any slot (except the one following ${n-1}$).  This gives $(n-1)A_{n-1}$ good permutations.
II.  Take a permutation on $n-1$ letters that has a single bad pair and insert the $n$ in the middle of the bad pair.  There are $n-2$ bad pairs amongst the $n-1$ letters and there are $A_{n-2}$ ways to arrange the $n-1$ letters so that the arrangement contains the specified bad pair and no other bad pairs.  This gives $(n-2)A_{n-2}$ good permutations on the $n$ letters.
Thus we have the regression $$A_n=(n-1)A_{n-1}+(n-2)A_{n-2}$$ Easy to see that $A_1=1=A_2$ so the first few terms of our regression are $$\{1,1,3,11,53,309,2119,16687,148329\}$$
Of course, this matches the sequence identified by @GerryMyerson in another posted solution.
A: Let $A_i$ be the set of permutations with the pattern $i, i+1$ for $1\le i\le 8$ and S the set of all permutations.
Using Inclusion-Exclusion, we have that
$\displaystyle\big|\overline{A_1}\cap\cdots\cap\overline{A_8}\big|=\big|S\big|-\sum_{i}\big|A_i\big|+\sum_{i<j}\big|A_i\cap A_j\big|-\sum_{i<j<k}\big|A_i\cap A_j\cap A_k\big|+\cdots$
$\displaystyle=9!-\binom{8}{1}8!+\binom{8}{2}7!-\binom{8}{3}6!+\binom{8}{4}5!-\binom{8}{5}4!+\binom{8}{6}3!-\binom{8}{7}2!+\binom{8}{8}1!$
$=148, 329$
(Notice that this equals $D_8+D_9=14,833+133,496$.)
A: Let us do it step by step 
First take total permutation = 9!(With out any constraint and no repetition)
Ok then as we know 12 in a sequence is not allowed so calculate total number of permutation when there is 12 = 7!
There are total 8 pairs so Ans should be 9!-8*(7!)=322560
