I'm studying for a linear algebra exam and one of the questions on a practice exam is as follows:
For which positive integers n does there exist a matrix $A\in\mathbb{R}^{n\times n}$ such that $A^2+A+I=0$?
Note: Here I is the identity matrix.
I know how to solve it for $A^2 + I=0$ by rearranging it as $A^2=-I$ then taking the determinant of both sides to get $\det(A)^2=(-1)^n$ and because $\det(A)^2$ must be positive there is no solution for odd values of n.
When I apply this technique to the above question I get: $A^2+A=-I\implies A(A+I)=-I\implies \det(A)\det(A+I)=(-1)^n$ but I'm stuck there because if $\det(A)<0$ then $\det(A+I)$ can be positive or negative so I can't use the same argument as above. I've tried manipulating the equation in other ways and applying the determinant and haven't been able to come up with anything.
Any help is appreciated!