Solution (source code)

= Solution

Applying $A^2=A$ to an <eigenvector> gives $\lambda_j^2=\lambda_j$, so each <eigenvalue> is either zero or one. If all are one, the <spectral theorem> gives $A=I$, hence $\det A=1$ and $\operatorname{tr}A=n$. Otherwise, if $m$ eigenvalues are one, with $0\leq m<n$, then
$$
\boxed{\det A=0,\qquad\operatorname{tr}A=m<n.}
$$
Thus the <trace> of this <orthogonal projection> equals its <rank>, including $m=0$ for the zero matrix.