n balls that are numbered $1, 2, \ldots, n$ are randomly distributed into $n$ cells that are also numbered $1, 2, \dots, n$. Every cell can place exactly $1$ ball. Let $X$ be the number of balls that were put into cells with identical numbers. Compute $E(X)$.
So from what I understand so far, I would have to find the general formula of $P(X = k)$ for $k = 1,2,\ldots n$
For $P(X = n)$ it is quite simple which is 1/n! For $P(X = k), 1 \le k < n$, I am stuck as I have only figured out a way of choosing the cells which are identical with the numbers on the ball which is just $n$ choose $k$. What about the rest of the cells? For example, we have $5$ cells. $2$ of the cells are going to be identical with the number on the balls. That is just $5$ choose $2$. What about the other $3$ cells? If using brute force, out of the $6$ ways of putting the balls into the cells, only $2$ would suit our condition. How do we find the general formula for it?
Sorry if my notation is not correct but I hope you understand what I am asking.