On average, how much money do I expect to have to spend to "theoretically" have to win the game? Game is very simple, a bag with 3 balls {Red, Blue, Green}
You play by picking the ball with equal probability.
If you did not get Red, you need to pay a fine of 20,000. 
If you get Red the game stop and you win. (You only care about winning)
How much money do you need to have in order to win the game? 
I ran a basic simulation
let winSoFar = 0;
let numberOfSimulation = 1000000;
let totalFine = 0;
while (winSoFar < numberOfSimulation) {
  while (true) {
    const number = random.from(1,2,3);
    if (number !== 3) {
      totalFine+=20000;
    } else {
      winSoFar++;
      break;
    }
  }
}
console.log(totalFine/numberOfSimulation);

It always give me around 40,000. I wonder how to get this mathematically? Is this the same as the term expected cost?
 A: Let $X$ denotes the number of rounds needed to win the game. 
We know that
$$P(X=r)=(1-p)^{r-1}p$$ i.e.$$X\sim\mathrm{Geo}(p)$$
where $p$ is the probability of winning a particular round, in this case, the probability of getting red. That is,
$$p=\frac13$$
The expected number of rounds needed is $$E(X)=\sum_{r=1}^\infty{rP(X=r)}=\frac1p=3$$
Hence, you are expected to lose $2$ rounds, and are expected to need 
$$ $40000$$
initially to win.
BUT  in order to SURELY win the game you will need an infinite amount of money since there is no finite number of rounds where you will definitely win within.
A: The event of you winning this game follows a geometric distribution - either you pick the red ball (with prob $1/3$) and win, losing no money, or you don't and you lose, costing you $20,000$.
The expectation of a geometric distribution with probability $p$ is $1/p$. So here, you are expected to have to play $\frac1{1/3}=3$ times, where you win on the third try. So you lost twice, therefore spent $40,000$.
