The question is whether a given matrix $$ \begin{pmatrix} 1 & 0 & c & d\\ 0 & 2 & e & f \\ 0 & 0 & 3 & g \\ 0 & 0 & 0 & 4\\ \end{pmatrix} $$ satisfies $f(A) = A^2 - 5A +4I=0$?
My attempt was to use the Cayley–Hamilton theorem $$ \Delta(\lambda)=\Pi_{k=1}^4(\lambda - k)^4 = (\lambda-2)(\lambda-3)(\lambda^2-5\lambda+4)=0. $$ Then $$ \Delta(A) = (A-2)(A-3)(A^2-5A+4)=(A-2)(A-3)f(A)=0. $$ But in general it does not mean that $f(A)$ is $0$. Moreover, by some numeric examples I see that in general $f(A)\neq0$. Is there any theorem or consequnce that I am missing?