How many permutations $f: \{1,2,3,4,5\} \rightarrow \{1,2,3,4,5\}$ have the property that $f(i)=i$ for at least two values of $i$?
I'm just struggling with this inclusion/exclusion question. I figured the best way would be to subtract (the cases where $f(i)=i$ holds for $1$ or $0$ values) from $5!$ ..not sure where to go from there.
There is $1$ permuatation that fixes $5$ elements.
There are no permutations that fix $4$ elements.
There are ${5 \choose 3} = 10$ permuations that fix $3$ elements (the other two are switched around).
There are $2 {5 \choose 2} = 20$ permutations that fix $2$ elements, because there are $5 \choose 2$ ways to pick the elements that are fixed and $2$ ways to permute the remaining $3$ elements.
So the final answer is $31$.