$A$ is $n\times n$ complex matrix with $A^2=A$. then need to show that Rank$A$=Trace$A$ So, I have that $A^n=A$ for every natural number $n$ which gives me that determinant of $A$ is either $0$ or the $(n-1)^{th}$ roots of unity, but I don't know how to take it from here.What do I do now? Thanks in advance!

For $x\in\Bbb R^n$ we have $x=(x-Ax)+Ax$ and since $x-Ax\in\ker A$ and $Ax\in Im (A)$ and by the rank-nullity theorem we have
$$\Bbb R^n=Im(A)\oplus \ker(A)$$
Let $p=rank(A)$ and let $\mathcal B=(e_1,\ldots,e_p)$ a basis of $Im(A)$ and $(e_{p+1},\ldots,e_n)$ a basis of $\ker A$ so $(e_1,\ldots,e_n)$ is a basis of $\Bbb R^n$. It's easy to prove that $x\in Im(A)\iff Ax=x$ so we see that $A$ is similar to this matrix (relative to the basis $\mathcal B$)
$$D=diag(\underbrace{1,\ldots,1}_{p\,\text{times}},0,\ldots,0)$$
hence
$$Tr(A)=Tr(D)=p=rank(A)$$
