I have just tried this out. It seems to work pretty well.
In my first try, I got
You have lasted 134045119 bets
https://jsfiddle.net/dd1atesr/1/Also, that doesn't simulate the odds of this happening in real life, because there would be times where you would stop the program.