Let $n$ be an integer greater than or equal to 2 and let $A$ be a $n^{th}$ order complex square matrix. Show that if $A^{n-1}$ is not diagonalizable and $A^n$ is diagonalizable, then $A^n=0$.
I have tried to think of a way to prove that but couldn't. I know that, If a matrix is diagonalizable over a field $F$ if and only if its minimal polynomial is a product of distinct linear factors over $F$. Can we use this to prove it or what is the proper way to think about it?
Write $\mathbb{C}^n$ as a direct sum of characteristic spaces $G_{\lambda_i}$ for $A$. Then, for each $G_{\lambda_i}$, $A^n$ is an endomorphism of this space and the $n$-th power of $\lambda_i I+\nu$, for some nilpotent $\nu$, so $\lambda_i^n$ is its only eigenvalue and $A^n_{|G_{\lambda_i}}=\lambda_i^n I$.
If $\lambda_i \neq 0$, then $A_{|G_{\lambda_i}}$ vanishes the polynomial $X^n-\lambda_i^n$ which has simple roots, so $A_{|G_{\lambda_i}}$ is diagonalizable.
It follows that $A^{n-1}_{|G_0}$ is not diagonalizable (in particular nonzero), while $A^n_{|G_0}=0$ by Cayley-Hamilton. Let $d$ be the dimension of $G_0$, $A_{|G_0}$ is nilpotent so $A^d_{|G_0}=0$. So $d > n-1$ thus $d=n$, hence $G_0=\mathbb{C}^n$. Thus $A$ nilpotent and by Cayley-Hamilton $A^n=0$.