I found an interesting question on quora and need help in solving this question. I've just started understanding permutations but could not understand as to how I can come up with a general formula for this problem. Consider all permutations of the numbers 1 to n. A good permutation is one where for any number i at position p in the permutation, i+1 is never at position p+1. For a given n, count the number of good permutations.
For example, for n = 3, the good permutations are:
1, 3, 2
2, 1, 3
3, 2, 1
Come up with a form of an answer which can be easily calculated.