Game analysis : Is it worth it to steal the box? There are $N$ dollars in a box. You have a probability $P$ (fixed) to win everything in the box and $1-P$ to pay a fee of $200$ dollars ($100$ go in the box, the other half is lost). You can try it as much as you want.
I've calculated mathematical expectation $E$ if one tries one time, two times or three times and solved the equation saying that $E\gt0$ to know when it is worth it to steal the box (depending on $N$).
I'd like to solve the problem for $n$ times trying to steal the box (stopping on a first success).
Here are the first iterations :


*

*Trying one time : $E = P\times N-200\times (1-P)$ (it is worth to steal the box when $E\gt0 \Leftrightarrow N>128$) 

*Trying two times (stopping if succeed on first attempt) : $E = P\times N-P\times(1-P)\times(N-100)-400\times(1-P)^2$ (it is $N-100$ and not $N-200$ because 100 dollars go in the box if you fail the first time). It is worth it if $E\gt0 \Leftrightarrow N>99$.  

*Third iteration : Becomes really complicated, I've solved it using Soulver (numerical method)


Is it possible to generalize the problem to $n$ tries ?
 A: Angela Richardson has given you a formula in her comment, but it is easier to find the overall optimal strategy.


*

*If it is worth playing a given finite number of turns then it is worth playing a potentially unlimited number of turns until you win, as there will be more money in the box later.

*If you will play a potentially unlimited number of turns until you win then you can ignore the 100 dollars that stays in the box, as you will get it back.

*So you need to compare the $N$ dollars you will gain against the 100 dollars you may lose several times which does not stay in the box.

*The expected number of times you lose before winning is $\frac{1-P}{P}$ [this is a negative binomial distribution] so you expect to lose $100\left(\frac{1-P}{P}\right)$ dollars before winning $N$ dollars.

*Your expected gain if you play until you win is $N-100\left(\frac{1-P}{P}\right)$ dollars.

*So if you have a linear utility of money and no attitude to risk you should play until you win if $N \gt 100\left(\frac{1-P}{P}\right)$ or equivalently if $P \gt \frac{100}{100+N}$, not play at all  if $N$ or $P$ are smaller than these bounds, and either play until you win or do not play at all if there is equality.

