Let $A$ be a commutative ring and $I$ a finitely generated ideal satisfying $I=I^2$. Prove that $I$ is generated by a single idempotent element.
Attempt: I know it exist an element $x \in A$ such that $x \equiv 1$ mod $I$ and $xI = 0$. By this I know that for this element $x$ we have $xy=0$ for all $y \in I$, and I can write $x + y_1 = 1$ for some $y_1 \in I$, multiplying this with $x$ gives $x^2=x$, thus I have found what I believe is our idempotent element we are looking for. Now i cant argue that $I=(x)$, what am I missing?