Solve $A=\text{adj}(A)$ in $\mathbf{M}_n(\mathbb{R})$. 
Solve the equation $A=\text{adj}(A)$ in $\mathbf{M}_n(\mathbb{R})$.
Where $\text{adj}(A)$ is the adjugate of $A$ (tranpose of cofactor matrix).

Here is what I know:

*

*$A^2=\det(A)I_n$


*$\text{rank(A)} \lt n-1 \implies \text{rank}(\text{adj}(A)) = 0$
Here is what I have done so far:
We have 3 cases:

*

*If $det(A) = 0$
Then $A^2=0$, thus $\text{rank}(A)\leq2-1=1$.
This implies $\text{rank(A)} = \text{rank}(\text{adj}(A)) \leq 1$
So $\text{rank}(A) = 0$, that is, $A=0$


*If $det(A) > 0$
Then $\left(X-\sqrt{\det A}\right)\left(X+\sqrt{\det A}\right)$ has $A$ as a root.
Thus $A$ is diagonalizable (since its minimal polynomial has simple roots) and its eigenvalues are a subset of $\{\sqrt{\det A}, -\sqrt{\det A} \}$.
Thus $A=P^{-1}
\begin{bmatrix}
\pm\sqrt{\det A} & &\\
& \ddots &\\
& & \pm\sqrt{\det A}
\end{bmatrix}
P$
Which we can verify as a solution to our equation.


*If $det(A) < 0$
Then $A^2=\det(A)I_n$.
Thus $B^2=-I_n$ with $B=\frac{1}{\sqrt{-\det A}}A$
How do I solve for $B$?
 A: We consider three possibilities according to the rank of $A$:

*

*$\operatorname{rank}(A)<n-1$. Then $\operatorname{adj}(A)=0$. Hence $A=0$. Clearly this is a valid solution.

*$\operatorname{rank}(A)=n-1$. Then $\operatorname{rank}(\operatorname{adj}(A))=1$. Therefore equation $A=\operatorname{adj}(A)$ is solvable only if $n=2$. However, it is evident that the equation
$$
\pmatrix{a&b\\ c&d}=\pmatrix{d&-b\\ -c&a}
$$
has not any rank-one solution.

*$A$ is nonsingular. Since $A=\operatorname{adj}(A)$, we have
$$
A^2=A\operatorname{adj}(A)=\det(A)I.\tag{$\dagger$}
$$
Take determinants on both sides, we get $\det(A)^2=\det(A)^n$. Therefore $\det(A)=\pm1$. If $\det(A)=-1$, then $A^2+I=0$. Since $x^2+1$ is irreducible over $\mathbb R$, it is the minimal polynomial of $A$ and the characteristic polynomial of $A$ must be a power of $x^2+1$. But then $\det(A)=1$, which is a contradiction. Thus $\det(A)$ must be equal to $1$ and $A^2=I$. Hence $A$ is similar to $I_{n-k}\oplus-I_k$ for some even integer $k$.

In short, $A=\operatorname{adj}(A)$ if and only if $A=0$ or $A$ is similar to $I_{n-k}\oplus-I_k$ for some even integer $k$.
Two comments to your solution attempt:

*

*In your first case, the condition $A^2=0$ doesn't imply that the rank of $A$ is $1$. E.g. consider $A=\pmatrix{0&1\\ 0&0}\oplus\pmatrix{0&1\\ 0&0}$.

*In your second case, $\det(A)$ must be equal to $1$, as shown in my answer above. The number of negative eigenvalues must also be even, as the determinant is positive.

A: user1551 has already posted an answer, but i would like to explain why $det(A)\geq0$ and case 3 doesnt have solutions.
Suppose $det(A)<0$
A has a negative eigenvalue k.
$Ax=kx$
$det(A)x=A^2x=k^2x$
$0>det(A)=k^2>0$
contradiction
