I have a sequence of $n$ Bernoulli experiments each succeeding with probability $p$. In general, the number of successes $X$ follows the well-known binomial distribution:
$$P(X = k) = \begin{pmatrix} n\\ k \end{pmatrix} p^k(1-p)^{n-k}$$
However, I'm interested in the expected value of the number of experiments until the first success, assuming a maximum number of $n$ trials (if the experiment never succeeds, there will have been $n$ experiments attempted).
My reasoning is the following: if $n = 4$, the expected value will be (?):
$$ 1\cdot p + 2\cdot(1-p)p + 3\cdot(1-p)^2p + 4\cdot(1-p)^3p + 5(1-p)^5$$
Generalizing:
$$E = \sum_{i=1}^n i\cdot p(1-p)^{i-1}$$
However, the sum of these weights is not one, as it should be:
$$\sum_{i=1}^n p(1-p)^{i-1} \neq 1$$
Clearly I'm off somewhere. What am I missing?