Give an integer N (N<=5000). How many different premutations of sequence 1..n (p[1],p[2]...p[n]) so that p[i]<>i with 1<=i<=n. It means the i-th number in a permutation must be different with its index.
for example
input 2 output 1 (2,1)
input 3 output 2 {(2,3,1); (3,1,2)}
input 4 output 9
Can you give me a solution. thank you very much and sorry about my bad english. :)