I'm having a doubt in the proof of Corollary 2.5 from Atiyah-Macdonald's Introduction to Commutative Algebra (page 21).
The proof is simple: apply Proposition 2.4 (basically a version of Cayley-Hamilton's theorem) with the identity module homomorphism: from $$ \phi^n+a_1\phi^{n-1}+...+a_n \text{ and } \phi(x)=x, $$ we get $$ x + a_1 x + a_2 x + ... + a_{n-1}x+a_n = x(1+a_1+...+a_{n-1})+a_n. $$
Proof follows by picking $x=1+a_1+...+a_n$ as if you could put in evidence the factor $x$ from the previous expression. But you can't. There is no $x$ multiplying the last $a_n$.
Can someone go through some trouble and explain what I'm missing? Thanks in advance.