Definition: An endofunction $f: A \rightarrow A$ is idempotent if $f(f(x)) = f(x)$.
Question: Is there a formula for the number of endofunctions that are idempotent for a finite set?
Definition: An endofunction $f: A \rightarrow A$ is idempotent if $f(f(x)) = f(x)$.
Question: Is there a formula for the number of endofunctions that are idempotent for a finite set?
Every point in the range must have $f(x)=x,$ so the function is fully determined by the range, and where the points not in the range go. So say you choose $k$ points to be the range. Then, you can take each of the other $(n-k)$ points to any one of the $k$ points in the range. So there are $k^{n-k}$ choices here. So we have $$ \sum_{k=1}^n k^{n-k} {n\choose k}$$ functions.