When an ideal is generated by idempotents 2 As in my previous question When an ideal is generated by idempotents. Let $I$ be a finitely generated ideal of a commutative ring $R$ with identity such that for all prime ideals $P$ of $R$ with $I\not\subseteq P$ and each $n\in
\mathbb{N}$, $ I\subseteq (P+I)^{n}$. Can we show that $I$ is generated by idempotents?
 A: Take for example $R=k[x]/(x^2)$, with $k$ a field. Then $R$ is a local ring with maximal ideal $(x)$. 
Take $I=(x)$. Then it's trivially true that for all prime ideals $P$ such that $I$ is not in $P$ we have $I \subseteq (P+I)^n$, but $x$ is not an idempotent. 
More generally, one can construct a counterexample using any local ring with maximal ideal not generated by an idempotent. 
EDIT: To give another counterexample when the set of primes not containing $I$ is nonempty, take $R=k[x]/(x(x+1))$, $k$ a field and $I=(x)$. Then the only prime not containing $I$ in $R$ is the prime $P=(x+1)$. But $I$ is not contained in $P$ and $I$ and $P$ generate the unit ideal, so again the condition is trivially satisfied. 
My guess is that any variation of the statement with a hope to be true would have to assume that $I$ is not prime. 
A: Let $R=\mathbb{Z}$ and let $I=2\mathbb{Z}$. All prime ideals $P$ distinct from $I$ satisfy $I\subseteq (P+I)^{n}$ for all $n$. But $I$ cannot be generated by idempotents, as the only idempotents in $R$ are $0$ and $1$.
