Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a set $S = \{ 1,2,3,4,5,6,7 \} $

I know that the number of bijective functions $S\rightarrow S$ without any restrictions is $7!$, but how can I count the number of bijective functions $ \phi : S \rightarrow S$ such that $\phi (x) \not= x$ for all $x \in S$?

share|cite|improve this question
These are the derangements. Please see the Wikipedia article. – André Nicolas Feb 18 '14 at 2:18
up vote 4 down vote accepted

This is the same as the number of derrangements between sets of size 7. Also know as 7 subfactorial denoted $!7$

derrangements do not have a nice closed formula, however they do obey the recurrence relation


the first $7$ values are $0,1,2,9,44,265,1854$. So $!7=1854$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.