<s>[INST] If $A$ is a square matrix such that $A^{27}=A^{64}=I$ then $A=I$ 
If $A$ is a square matrix such that $A^{27}=A^{64}=I$ then $A=I$.

What I did is to subtract I from both sides of the equation:
$$A^{27}-I=A^{64}-I=0$$
then:
\begin{align*}
A^{27}-I &= (A-I)(A+A^2+A^3+\dots+A^{26})=0\\
A^{64}-I &= (A-I)(A+A^2+A^3+\dots+A^{63})=0.
\end{align*}
So from what I understand, either $A=I$ (as needed) or $A+A^2+A^3+\dots+A^{26}=0$ or $A+A^2+A^3+\dots+A^{63}=0$.
At this point I got stuck. By the way, I found out that $A$ is an invertible matrix because if $A^{27}=I$ then also $A^{26}A=AA^{26}=I$ then $A^{26}=A^{-1}$.
Also I thought to use the contradiction proving by assuming that $A+A^2+A^3+\dots+A^{63}=0$, but because $A^{27}=I$, then:
$$A+A^2+A^3+\dots+A^{26}+I+A^{28}+\dots+A^{53}+I+A^{55}+\dots+A^{63}=0$$
but yet nothing.
Would appreciate your guidance, thanks!
 [/INST] \begin{align*}
& I = A^{64} = A^{2(27) + 10} = (A^{27})^2A^{10} = A^{10}\\
\implies & I = A^{27} = A^{2(10) + 7} = (A^{10})^2A^7 = A^7\\
\implies & I = A^{10} = A^{1(7)+3} = (A^7)^1A^3 = A^3\\
\implies & I = A^7 = A^{2(3) + 1} = (A^3)^2A = A.
\end{align*}
This is nothing more than the Euclidean algorithm applied to the exponents. The same procedure can be used to show that if $A^p =  I$ and $A^q = I$ with $p$ and $q$ coprime, then $A = I$.
</s>