Let $n ≥ 1$ be an integer. A function $f : \{1, 2, \ldots , n\} \to \{1, 2, \ldots, n\}$ is considered "valid", if there is at least one integer $i$ in $\{1, 2, \ldots, n\}$ for which $f(i) = i$.
Determine the number of valid functions.
I'm having problems understanding what this question is asking. I'm not even sure how to approach this. Could someone point me to the right direction? What technique should I be using to approach it?
I guess what's confusing me the most is this line here. Since I don't understand it.
A function $f : \{1, 2, \ldots, n\} \to \{1, 2, \ldots, n\}$
Let $A_i$ denote the number of functions for which $f(i) = i$. We need $\left|\cup_{i=1}^n A_i\right|$. Note that $|A_i| = n^{n-1}$. Also $|A_i \cap A_j| = n^{n-2}$. Thus by inclusion exclusion principle, $$\left|\cup_{i=1}^n A_i\right| = \binom{n}{1}n^{n-1} - \binom{n}{2}n^{n-2} +\cdots =n^n - (n-1)^n$$