TITLE: How to approach this counting problem?
QUESTION [7 upvotes]: 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\}$

REPLY [7 votes]: There $n^n$ functions $\{1,\dots,n\}\to\{1,\dots,n\}$ in total, since for every argument $i\in\{1,\dots,n\}$ we have $n$ choices.
There are $(n-1)^n$ functions that are not valid, since for these functions for every argument $i\in\{1,\dots,n\}$ we have $n-1$ choices (the choice "$i$" falls out).
Consequently there are $n^n-(n-1)^n$ valid functions.