vector spaces whose algebra of endomorphisms is generated by its idempotents Let $V$ be a $K$-vector space whose algebra of endomorphisms is generated (as a $K$-algebra) by its idempotents. 
Is $V$ necessarily finite dimensional?
EDIT (Jul 26 '14) A closely related question: 
Is there a field $K$ and a $K$-vector space whose algebra of endomorphisms of is not generated (as a $K$-algebra) by its idempotents?
 A: The purpose of this post is to prove:

(a) If $R$ is a ring (i.e. an associative ring with $1$), then any two by two matrix with entries in $R$ is a $\mathbb Z$-linear combination of products of two idempotents. 

Proof: We have 
\begin{align*}
\begin{pmatrix}a&b\\ c&d\end{pmatrix}&=\begin{pmatrix}1&a-1\\ 0&0\end{pmatrix}\begin{pmatrix}1&0\\ 1&0\end{pmatrix}+\begin{pmatrix}1&b+1\\ 0&0\end{pmatrix}-\begin{pmatrix}1&1\\ 0&0\end{pmatrix}\\ \\ 
&+\begin{pmatrix}0&0\\ d-1&1\end{pmatrix}\begin{pmatrix}0&1\\ 0&1\end{pmatrix}+\begin{pmatrix}1&0\\ c+1&0\end{pmatrix}-\begin{pmatrix}1&0\\ 1&0\end{pmatrix}.
\end{align*}
QED
George Lowther proved: 

(b) If $R$ is a ring, then any two by two matrix with entries in $R$ is a $\mathbb Z$-linear combination of products of three idempotents. 

George also explained that, in order to answer the question, it sufficed to prove:  

(c) If $R$ is a ring, then any two by two matrix with entries in $R$ is a $\mathbb Z$-linear combination of products of idempotents. 

Going from (b) to (a) reduces the number of factors from three down to two. This number cannot be reduced further, because, as George observed in a comment, a two by two matrix with entries in $R$ is not in general a $\mathbb Z$-linear combination of idempotents. 
Indeed, for trace reasons, 
$$
\begin{pmatrix}\frac12&0\\ 0&0\end{pmatrix}
$$ 
is not a $\mathbb Z$-linear combination of idempotents of $M_2(\mathbb Q)$.
In fact George shows that, if $R$ is a domain, then the condition that any two by two matrix with entries in $R$ is a $\mathbb Z$-linear combination of idempotents is equivalent to $R$ being a quotient of $\mathbb Z$.
The question about the least number of factors was raised by Jonas Meyer in a comment. Things will become clearer if we generalize slightly the setting. 
Let $K$ be a commutative ring and $R$ a $K$-algebra (associative with $1$). 
By our previous considerations, any two by two matrix with entries in $R$ is a $K$-linear combination of products of two idempotents, but in general not a $K$-linear combination of idempotents. 
Say that $R$ is $K$-nice, or nice over $K$, if any two by two matrix with entries in $R$ is a $K$-linear combination idempotents.
Jonas asked if $\operatorname{End}_K(V)$ (for $V$ a $K$-vector space) is $K$-nice.
One can also ask which rings are nice over their center.
In view of the above proof, $R$ is $K$-nice if and only if any matrix of the form 
$$
\begin{pmatrix}a&0\\ 0&0\end{pmatrix}
$$ 
is a $K$-linear combination of idempotents.
A: The algebra of endomorphisms of any vector space $V$ is generated by the idempotents.
The finite dimensional case is straightforward, so I will suppose that $V$ is infinite dimensional. Then (assuming the axiom of choice), we have $V\cong W\oplus W$ for some vector space $W$. In fact, we can take $W=V$, as a vector space is determined up to isomorphism by its dimension and, using the fact that $\kappa+\kappa=\kappa$ for infinite cardinals $\kappa$, we have
$$
\mathop{dim}(V\oplus V)=\mathop{dim}V+\mathop{dim}V=\mathop{dim}V.
$$
So, $V\cong V\oplus V$.
Writing $V\cong W\oplus W$, the endomorphisms of $V$ can be identified with the algebra $M_2(\mathrm{End}(W))$ of $2\times2$ matrices over the endomorphism ring of $W$. We can now express any element of this ring explicitly in terms of idempotents,
$$
\begin{align}
\left(\matrix{a&b\\c&d}\right)&=\left(\matrix{a-1&0\\0&0}\right)+\left(\matrix{1&b\\0&0}\right)+\left(\matrix{0&0\\c&1}\right)+\left(\matrix{0&0\\0&d-1}\right)\\ \\
&=\left(\matrix{1&a-2\\0&0}\right)\left(\matrix{1&0\\1&0}\right)+\left(\matrix{1&b\\0&0}\right)\\
&+\left(\matrix{0&0\\c&1}\right)+\left(\matrix{0&0\\1&d-2}\right)\left(\matrix{0&1\\0&1}\right).
\end{align}
$$
[Edit: I replaced the rhs with Pierre-Yves' much simpler variant]. It can be checked that all the matrices on the right hand side of the final equality are idempotents.
