You have an amount of money to bet on a fair coin flipping and landing on heads. How much should you bet as a function of your balance to maximize your probability of profiting if you play $x$ times?
[Math] Coin flip gamble
gamblingprobability
Related Solutions
Once $A$ has finished playing, ending with an amount $a$, the strategy for $B$ is simple and well-known: Use bold play. That is, aim for a target sum of $a+\epsilon$ and bet what is needed to reach this goal exactly or bet all, whatever is less. As seen for example here, the probability of $B$ reaching this target is maximized by this strategy and depends only on the initial proportion $\alpha:=\frac{100}{a+\epsilon}\in(0,1)$. (Of course, $B$ wins immediately if $a<100$). While the function $p(\alpha)$ that returns $B$'s winning probability is fractal and depends on the dyadic expansion of the number $\alpha$, we can for simplicyity (or a first approximate analysis) assume that $p(\alpha)=\alpha$: If the coin were fair, we would indeed have $p(\alpha)=\alpha$, and the coin is quite close to being fair. Also, we drop the $\epsilon$ as $B$ may chose it arbitrarily small. (This is the same as saying that $B$ wins in case of a tie).
In view of this, what should $A$ do? If $A$ does not play at all, $B$ wins with probability $\approx 1$. If $A$ decides to bet $x$ once and then stop, $B$ wins if either $A$ loses ($p=0.51$) and $B$ wins immediately or if $A$ wins $p=0.49$ and then $B$ wins (as seen above) with $p(\frac{100}{100+x})\approx \frac{100}{100+x}$. So if $A$ decides beforehand to play only once, she better bet all she has and thus wins the grand prize with probaility $\approx 0.49\cdot(1-p(\frac12))\approx \frac14$.
Assume $A$ wins the first round and has $200$. What is the best decision to do now? Betting $x<100$ will result in a winning probability of approximately $$0.49\cdot(1-\frac{100}{200+x})+0.51\cdot(1- \frac{100}{200-x}) $$ It looks like the best to do is stop playing (with winning probability $\approx\frac12$ now).
Alernatively, let us assume instead that $A$ employs bold play as well with a target sum $T>100$. Then the probability of reaching the target is $\approx \frac{100}{T}$, so the total probability of $A$ winning is approximately $$ \frac{100}T\cdot(1-\frac{100}T)$$ and this is maximized precisely when $T=200$. This repeats what we suspect from above:
The optimal strategy for $A$ is to play once and try to double, resulting in a winning probability $\approx \frac14$.
Admittedly, the optimality of this strategy for $A$ is not rigorously shown and especially there may be some gains from exploiting the detailed shape of $B$'s winnign probability function, but I am pretty sure this is a not-too-bad approximation.
You are taking a One-Dimensional Random Walk on the integers, starting at 0. With probability 1, you will visit every integer infinitely often, including the starting point, but also the point where you're broke. Curiously, if the random walk is expanded to two dimensions, the same result holds, but in three dimensions it's only a 34% chance to return back to the origin.
Best Answer
Seems like the previous answers didn't fully appreciate the question, which I think has multiple interpretations.
Let $A$ be your initial amount of money, and $x$ be the number of times you need to bet. Now there are two ambiguities:
Suppose (1) and (2) are both true. If $x$ is odd you have exactly a 50% chance of profiting, no matter what. However, if $x$ is even you have strictly less than a 50% chance of profiting. For example, if $x = 2$, then you have only a 25% chance of profiting.
Suppose (1) is false and (2) is true. Then clearly, you will simply bet some odd number of times $t \leq x$, and have a 50% chance of profiting.
Suppose (2) is false (regardless of (1)). Then you can actually achieve a $1 - .5^x$ chance of profiting. For each round $i$ until you win a coin toss, simply bet $A * .5^{x-i+1}$ dollars. $\sum_{i=1}^\infty A*.5^i = A$, so clearly you will never go broke, because $x$ is finite. However, each bet is more than the sum of all previous bets. Thus, once you win one coin toss, you will have more than $A$ dollars, and can simply bet a small enough sliver of your profits for the remaining bets to guarantee that you profit.