How many diagonalizable matrices are there in $\mathcal{M}_{n}(\mathbb{Z}/p\mathbb{Z})$ ? Where $p$ is a prime number.
Attempt : By definition a matrix is called diagonalizable if there exists an invertible matrix $P$ such that $P^{−1}AP$ is diagonal. Given that the number of non-singular matrices of $\mathcal{G}\mathcal{L}_{n}(\Bbb{Z}/p\Bbb{Z})$ is $\prod\limits^{n-1}_{i=0}(p^{n}-p^{i})$, we can prove this by counting the number of basis of $\Bbb{Z}/p\Bbb{Z}^{n}$. And the number of diagonal matrices is $p^n$. So basically I would say that the result is $$\prod\limits^{n-1}_{i=0}(p^{n}-p^{i})\times p^{n}.$$
Does I miss something ?
EDIT : Ok it's wrong according to Blue comments.
Your formula assumes that diagonal matrices can be represented as $PDP^{-1}$ for some diagonal matrix $D$ and invertible matrix $P$ uniquely. This is not true: $D$ is unique, but $P$ isn't.
Without loss of generality we can work over arbitrary $\Bbb F_q$; this adds no difficult.
We need to compute the size of the orbit of a given diagonal matrix under the action of ${\rm GL}_n(\Bbb F_q)$ and then sum over all possible diagonal matrices modulo permutation. By the orbit-stabilizer theorem, the size of an orbit is equal to $|{\rm GL}_n(\Bbb F_q)|$ divided by the stabilizer of a given matrix.
Given a diagonal matrix ${\rm diag}(\lambda_1,\cdots,\lambda_n)$, which $P\in{\rm GL}_n(\Bbb F_q)$ act trivially on it by conjugation?
First thoughts: this is equivalent to $P\in {\rm GL}_n(\Bbb F_q)$ preserving the decomposition of $\Bbb F_q^n$ into eigenspaces, which means such $P$ are direct sums of arbitrary invertible maps on them.
Using this approach I get
$$\sum_{r=1}^n \binom{q}{r}\sum_{\substack{m\vdash n \\ {\rm len}(m)=r}}\langle m\rangle^r\frac{|{\rm GL}_n(\Bbb F_q)|}{|{\rm GL}_{m_1}(\Bbb F_q)|\cdots|{\rm GL}_{m_r}(\Bbb F_q)|}.$$
where $\langle m\rangle$ for my purposes denotes the number of distinct entires in the $r$-tuple $m$.
(Think I finally have it right.) Not sure how to simplify it though.