Conditional probability to Conditional expectation My first related question is this link.
enter link description here
Expected value of geometric distribution is
$$c=E(X)$$
$$c=0\times p+(1+c)\times q =q+cq$$
$$c=\frac{q}{p}$$
when $X= number \ of \ failures \ before \ the \ 1st \ success$
I just learned about conditioning through $Statistics \ 110$, lecture in Harvard. 
So I want to proof that equation using conditioning.

$$P(X)=P(X\mid A_1)P(A_1)+P(X\mid A_2)P(A_2)$$

So,
$$E(X)=\sum\limits_{x=1}^{\infty} xP(X=x)=\sum\limits_{x=1}^{\infty}xP(X=x\mid A_1)P(A_1)+\sum\limits_{x=1}^{\infty}xP(X=x\mid A_2)P(A_2)$$
$$when \ P(A_1)=P(1st \ success)=p, \ P(A_2)=P(1st \ failure)=q$$
I know
$$\sum\limits_{x=1}^{\infty}xP(X=x\mid A_1)P(A_1)=0$$ because $P(X=x\mid A_1)=0 \ ,\ for \ any \ positive \ integer \ x $. And now we have $q\sum\limits_{x=1}^{\infty}xP(X=x\mid A_2)$ only.
But I have no idea that covert $\sum\limits_{x=1}^{\infty}xP(X=x\mid A_2)$ into $(1+c)$ algebraicly. 
I want to know that this process has any error and some idea to complete this proof.
 A: $X$ is the count of Bernoulli trials before the first success.
$A_1$ and $A_2$ are the events of a success and failure (respectively) on the first trial.   These events are mutually exclusive and exhaustive; they partition the outcome space.
$\begin{align}
\mathsf E(X) & = \sum_{x=0}^\infty x\mathsf P(X=x)
& \text{by definition of expectation}
\\[1ex] & = \sum_{x=0}^\infty x\,\big(\mathsf P(X=x\cap A_1)+\mathsf P(X=x\cap A_2)\big)
& \text{Law of Total Probability}
\\[1ex] & = \sum_{x=0}^\infty x\,\big(\mathsf P(X=x\mid A_1)\mathsf P(A_1)+\mathsf P(X=x\mid A_2)\mathsf P(A_2)\big)
& \text{by Conditional Probability}
\\[1ex] & = \mathsf P(A_1)\sum_{x=0}^\infty x\,\mathsf P(X=x\mid A_1)+\mathsf P(A_2)\sum_{x=0}^\infty x\, \mathsf P(X=x\mid A_2)
& \text{Rearranging}
\\[1ex] & = \mathsf P(A_1)\,\mathsf E(X\mid A_1)+\mathsf P(A_2)\,\mathsf E(X\mid A_2)
& \text{by definition of expectation}
\end{align}$
This result is called the Law of Iterated Expectation.

Notice that $A_1$ is the event that $X=0$ , and that $A_2$ is the event that $X>0$.
$\begin{align}
\mathsf E(X)
 & = \mathsf P(X=0)\,\mathsf E(X\mid X=0) + \mathsf P(X>0)\,\mathsf E(X\mid X>0) & \text{Law of Iterated Expectation}
\\[1ex] & = p\,\mathsf E(X\mid X=0) + (1-p)\,\mathsf E(X\mid X>0) & \mathsf P(X=0)=p
\\[1ex] & = p\cdot 0 + (1-p)\,\mathsf E(X\mid X>0) & \mathsf E(X\mid X=0)=0
\\[1ex] & = p\cdot 0 + (1-p)\,(1+\mathsf E(X)) & \mathsf E(X\mid X>0)=1+\mathsf E(X)
\\[0ex] && \text{because the distribution is memoriless.}
\\[2ex]
\therefore \mathsf E(X) & = \frac{1-p}p
\end{align}$


why $\mathsf E(X\mid A_2)=1+\mathsf E(X)$ ? Memoriless means 'following next steps are completely independent from the previous step'?

Yes, and that means the expected number of failures after the $n^\text{th}$ trial and before the next success is the same as the expected number of failures after the $0^\text{th}$ trial and before the first success, for any $n$. 
$\mathsf E(X\mid X>0)$ is the expected count of failures before the first success given that the first trial was a failure.   That will be the first trial plus the expected count of failures after that first trial and before the first success.   That is: $1+\mathsf E(X)$.
