Give $A \in M_n(\mathbb{C})$ such that $A^2=A$, Then Prove that $rank(A)=Tr(A)$
My try:
I took two cases:
Case $1.$ If $A$ is Invertible then we have the only idempotent matrix as $A=I$
$$Rank(I)=n=Tr(I)$$
Case $2.$ If $A$ is Non invertible Then
$Rank(A) \lt n$
But now how to prove it is Trace?