The guide
A small edge against you is a slow leak: what repeated bets really do
Gambler's ruin explains why a game with a slight edge against you still ends in loss, how long that takes, and what an exact fraction tells you that a simulation cannot.
- 59049/67849 chance of reaching 15 from 5 at p = 0.6 (about 0.8703)
- 0.119175 chance of doubling 50 units when p = 0.49
- 100 rounds average length of a fair game from 10 to 20
- 0.0000266 chance of doubling 100 units on an 18 in 38 bet
- 5.26% expected loss per unit on an even-money double-zero bet
Read the full guide Fold the guide
Flip a coin that lands heads six times in ten and stake one unit on each flip. Start with five units and stop when you hold fifteen or none. Most people guess that reaching fifteen is somewhat better than even. The exact chance is 59049/67849, about 0.8703, and it comes from a rule short enough to write on one line.
The same rule explains why a casino can offer a bet that looks almost fair and still empty every bankroll that stays at the table long enough.
What ruin means
Picture a walk along a line of whole numbers. You stand at your fortune, called i. Each round you step up one unit with chance p or down one with chance q, which is 1 minus p. Two walls stop the walk: zero, where you are ruined, and a target N, where you walk away. The Wikipedia article on gambler’s ruin puts the headline result plainly: a gambler who plays a game with non-positive expected value will eventually go bankrupt, whatever betting system is used.
That sentence hides two separate questions. One is whether you hit the target or the floor first. The other is how long the walk lasts. A fair game and a slightly unfair game can look alike over twenty rounds and then part company completely over twenty thousand.
The problem is old. Wikipedia dates the earliest known mention to a letter from Pascal to Fermat in 1656. Huygens reformulated it and published it in his treatise on reasoning in games of chance in 1657, a treatise whose first page the MacTutor biography of Huygens reproduces. Grinstead and Snell add a later chapter in the story: in 1711 de Moivre gave an ingenious derivation of the chance of ruin using counters whose values make the game fair.
Notice what is not in the problem. The stake never changes, the chance p never changes, and nothing is drawn. Those limits are what make an exact answer possible, and they are also where the model stops.
From a recurrence to a closed form
Let P(k) be the chance of reaching N before zero when you hold k units. At zero the chance is 0, and at N it is 1. For every fortune in between, one round happens first. With chance p you move to k plus 1, and with chance q you move to k minus 1, so P(k) equals p times P(k+1) plus q times P(k-1).
Grinstead and Snell write down exactly this relationship and rearrange it. The difference between neighbours changes by the fixed factor q over p each step. Add those differences up with the two boundary values pinned and a geometric sum appears, which is why the answer has powers in it.
When p and q differ, write r for q over p. The chance of reaching N from i is then (1 - r^i) divided by (1 - r^N). The same book shows that the chance of ruin and the chance of success add to exactly 1, so the game ends with certainty and nobody plays for ever. When p equals one half, the formula collapses to i divided by N: your chance of reaching the target is simply your share of it.
Here is the example that opened the essay. With p = 0.6, r is 2/3, and from 5 to 15 the formula gives (1 - (2/3)^5) / (1 - (2/3)^15), which reduces to 59049/67849. The Wikipedia article gives the same 59049/67849 for this very game. The chance of ruin is the rest, 8800/67849, about 0.1297.
Against a bank with no limit the target disappears. Grinstead and Snell note that letting the target grow without bound leaves a ruin chance of (q/p)^i when q is below p, and 1 when q is above p or equal to it. With p = 0.6 and i = 5 that is (2/3)^5, about 0.131687. Even a clear edge cannot protect you from an early run of losses, only make it unlikely.
Why a small edge compounds
Roulette is the standard case study. According to the Wikipedia page, an American wheel has a second green pocket, so it has 38 pockets, and a bet on red wins on 18 of them. The expected value of a one-unit bet works out to 36 divided by the number of pockets, minus 1, which is a loss of 2/38 per unit, about 5.26%.
That sounds mild. Try it in the calculator. Take p = 18/38, start with 100 units, and aim for 200. The chance of doubling is about 0.0000266, roughly one in 37,650, and the game lasts about 1,900 rounds on average. A loss of about five percent per bet is small, yet over hundreds of rounds it makes the doubling all but impossible.
Now compare a gentler edge. Set p = 0.49, start at 50 and aim for 100. A fair game gives exactly one half. At 0.49 the chance falls to 0.119175, and the mean length is about 1,904 rounds. One percentage point of edge cuts the chance of doubling from fifty percent to about twelve percent.
Why so steep? The factor r multiplies at every step of the walk. At p = 0.49, r is 51/49, a little above 1, and it is raised to the powers 50 and 100. Small per-step edges become large over many steps, which is the geometric growth the closed form encodes.
Laverty and Kelly compute ruin chances for various roulette bets in an open-access paper. Their abstract reports that lower goals of gain are associated with a lower chance of ruin, while larger bets and larger payoffs raise it. That agrees with the direction the formula gives: aim lower and stop sooner, and the house has fewer rounds to work with.
How long the game lasts
The second question has its own formula. For a fair game that starts at i and stops at N, the expected number of rounds is i times (N - i). From 10 to 20 that is 10 times 10, so 100 rounds. From 50 to 100 it is 2,500. From the midpoint the product is a quarter of N squared, so doubling N quadruples the expected length.
For an unfair game the expected length changes. It is (i - N times the win chance) divided by (q - p), and it can be shorter or longer than i(N - i). With p = 0.6, 5 and 15, the expected length is about 40.2725 rounds, not the 50 that the fair-game product would suggest. Using the wrong formula is a common slip, and so is swapping p and q. Swapping them in the example above gives 0.0151 instead of 0.8703.
How can the same program be trusted? The calculator solves the underlying linear equations on its own, using exact fractions and plain Gaussian elimination, for every target up to 60, and compares each starting fortune with the closed form. It also builds the exact distribution after any number of rounds by stepping the whole walk forward one round at a time, up to 5,000 rounds and a target of 200, and it confirms that won, ruined and still playing add to exactly 1.
What a simulation can and cannot say
A simulation plays the game many times with a random generator and counts. It gives an estimate with a spread, not a fraction. The calculator uses the xoshiro128++ generator described on Vigna’s page, written with the 32-bit multiply that JavaScript provides as Math.imul for seeding, and the seed is yours, so a run can be repeated exactly.
For 200,000 games of the p = 0.6 example the win share lands within a few thousandths of 0.8703, inside the five-standard-error band the page prints. That is a MATCH, which is evidence and not proof. Run it with fewer games and the band widens. A simulation of a rare event is weakest of all: if the true chance is 0.0000266, then 200,000 games should hold only about five wins, and a few more or fewer is normal.
Exactness has a price too. The numbers behind a closed form grow fast. For a target of 10,000 the integers inside the fraction run to thousands of digits, which is why the page uses BigInt, the integer type that MDN shows holding values beyond the safe-integer limit of ordinary numbers, and why it does the longest work in a separate worker thread so the page keeps responding. The Python fractions module, which an independent check uses, works in exact rationals in the same way, and NumPy’s random Generator, whose default bit generator is PCG64, gives a second simulation to compare with.
The limits are real. The calculator assumes one unit per round and a fixed chance, so it does not model betting systems that change the stake, draws, fees or several players. It also says nothing about luck, only about odds. If you can repeat a bet only a few times, ruin is a rare event; if you can repeat it without limit, with an edge against you, it is the only event left.
Sources
Every source consulted for this guide. Links checked November 10, 2026.
- Gambler's ruin - Wikipedia Wikipedia (CC BY-SA 4.0)
- Roulette - Wikipedia Wikipedia (CC BY-SA 4.0)
- Grinstead and Snell's Introduction to Probability Charles M. Grinstead and J. Laurie Snell, the CHANCE Project, Dartmouth College (GNU Free Documentation License)
- Techniques for Computing the Probability of a Gambler's Ruin with Applications to Playing Roulette William Henry Laverty and Ivan William Kelly, American Journal of Theoretical and Applied Statistics, 2023 (CC BY 4.0)
- Christiaan Huygens (1629 - 1695) - Biography - MacTutor History of Mathematics MacTutor, University of St Andrews (CC BY-SA 4.0)
- BigInt - JavaScript | MDN MDN Web Docs (Creative Commons licence)
- Web Workers API - Web APIs | MDN MDN Web Docs (Creative Commons licence)
- Math.imul() - JavaScript | MDN MDN Web Docs (Creative Commons licence)
- A PRNG shootout Sebastiano Vigna, Universita degli Studi di Milano (generator code in the public domain)
- fractions - Rational numbers - Python 3.13 documentation Python Software Foundation (PSF licence)
- Random Generator - NumPy v2.5 Manual NumPy Developers (BSD licence)