The System That Could Not Lose
A Man Who Had Found the Secret
In the summer of 1863 a Russian novelist in his forties arrived in Wiesbaden with a young lover, very little money and a great many troubles, and sat down at the roulette table. He won. On the first of September he wrote home to explain that he had discovered the secret of the game. It was simple, he said: keep your head, whatever happens, and never get excited — “you just can’t lose that way and are sure to win.”
A week later he had lost the winnings, then more, and pawned his watch in Geneva.
His name was Fyodor Dostoevsky, and the secret would cost him the next eight years.

The Contract
The next year was a catastrophe. His wife died, then his brother, and Dostoevsky took on his brother’s family and the debts of the magazine they had run together, which promptly failed.
In July 1865, desperate for cash, he signed a contract with a publisher named Stellovsky. It paid him money he needed at once, and it carried a clause that should have frightened him: he must deliver a new novel by 1 November 1866. If he missed the date, Stellovsky would own everything he wrote for the next nine years, without paying him a kopeck.
He took Stellovsky’s money to Wiesbaden and lost all of it. “I have lost everything already,” he wrote to Turgenev, “just everything, including my watch.”
Then he spent 1866 writing Crime and Punishment instead. A month before the deadline he had not written a line of the novel he owed.
On 4 October 1866 he hired a twenty-year-old stenography student, Anna Snitkina, and began to dictate. The novel he dictated was about a young man destroyed by roulette. It was finished on 29 October — twenty-six days — and called The Gambler. Stellovsky, who stood to gain nine years of free novels, had left town so that it could not be delivered; the manuscript was registered with the authorities, a notary in one account and a police office in others, hours before the deadline.

In February 1867 he married the stenographer.
The System Every Gambler Knew
Dostoevsky’s system was composure. The system everyone else at the table knew was older, simpler and far more convincing. It was popular in eighteenth-century France, and it is called the martingale.
Bet one unit on red. If you lose, double the bet. If you lose again, double again. The moment red comes up, you have won back every loss plus one unit, so you start again at one. Every run of this system ends the same way: one unit up.
A century before Dostoevsky, Casanova played it in Venice, and his memoirs describe exactly how good it feels. “Playing the martingale, and doubling my stakes continuously, I won every day during the remainder of the carnival. I was fortunate enough never to lose the sixth card, and, if I had lost it, I should have been without money to play, for I had two thousand sequins on that card.”
Put numbers on it. A European wheel has 37 pockets, 18 of them red, so a bet on red wins with probability $p = 18/37$ and loses with $q = 19/37$. Bring a bankroll of 1,023 units and you can cover ten doublings: $1 + 2 + 4 + \cdots + 512$. A run fails only if ten spins in a row go against you, which happens once in 784 runs. Play twenty runs a night and you walk out ahead on 97.5% of nights — thirty-nine nights out of forty.
The Fortieth Night
Casanova’s came soon enough. Later in the same memoirs: “I still played on the martingale, but with such bad luck that I was soon left without a sequin.” He sold his lover’s diamonds, and lost what they fetched.
For the rest of us, on the fortieth night the ladder breaks, and you lose 1,023 units: the profit of fifty-one winning nights, in one run.
Average it out. A run of $n$ doublings wins one unit unless all $n$ spins lose, in which case it costs $2^n – 1$:
On this wheel $q = 19/37$, so $2q$ is $38/37$, just above one, so $(2q)^n$ grows and every extra doubling makes the expected result worse, not better. With ten doublings it is $-0.306$ units a run, or $-6.1$ a night.
The deeper surprise is how much money that is per unit you actually put on the table. The $i$-th bet of a run, of size $2^i$, is only placed if the first $i$ spins lost, so the expected amount staked in a run is
Exactly one thirty-seventh — the house edge on a single spin, at every depth of doubling. The system does not change how much you lose for every unit you bet. It changes when you lose it: a little won almost every night, and all of it back at once on the fortieth.
On a perfectly fair coin, with $q = 1/2$, equation (1) gives $1 – 1^n = 0$ for every $n$. Even a fair game gives the system nothing.

The crowd is the most honest way to see it. Early on nearly everyone is ahead, which is exactly what makes the system feel true. But the catastrophe comes about every forty nights, and more likely than not within twenty-eight. After forty nights only 36% of the gamblers are ahead of where they started; after two hundred, a quarter are, and nearly half no longer have enough left to cover one ladder. That grey line is a real draw from the simulation, not a chosen example: 1,820 units up after three months, and out of the game two months later.
There is a way to make the ladder never break: make it infinite. Then red must come up eventually, and every run really does end one unit up. But the size of the bet you should expect to need is the sum in equation (2) with no end to it, and since $q > 1/2$ that sum has no limit. After ten doublings it is 11 units, after a hundred it is 496, after a thousand it is more than ten trillion. A system that never loses needs a bank that never runs out.
That this is a theorem, not bad luck, is due to Joseph Doob. His optional stopping theorem says that if a game is unfavourable spin by spin, then no rule for how much to bet, when to bet or when to walk away can make it favourable — as long as your money is finite. And the mathematics took its name from the gamblers. When Jean Ville needed a word in 1939 for a process that is fair on average, whatever you know about its past, he borrowed martingale from the betting system. The theorem that kills the system is named after it.
Algorithm — The Martingale, and the Proof It Loses
input: n, the doublings your bankroll covers (bankroll = 2^n - 1)
q = 19/37, the chance a bet on red loses
# ---- one run -------------------------------------------------
stake <- 1
repeat:
bet stake on red
if red: return +1 # every loss recovered, plus one
if stake = 2^(n-1): return -(2^n - 1) # the ladder is spent
stake <- 2 * stake
# ---- what it is worth, exactly -------------------------------
E_run <- 1 - (2q)^n # negative whenever q > 1/2
E_staked <- ((2q)^n - 1) / (2q - 1)
E_run / E_staked = -(2q - 1) = -1/37 # the house edge, at any n
# ---- the check, sharing nothing with the formulas ------------
spin 400,000 runs of ten doublings with a random wheel
report the failure rate, the mean result and the loss per unit
staked beside the exact values above
return E_run and the loss per unit staked
The check agrees: in 400,000 simulated runs the ladder broke once in 781 (exactly, once in 784), the mean result was $-0.311$ against $-0.306$, and the loss per unit staked came out at $2.76\%$ against $2.70\%$.
Composure Is Not an Edge
Dostoevsky’s own system fails for the same reason the martingale does, only faster. Keeping your head changes nothing about the wheel; the wheel does not know you are calm. (It does not know anything, which is the subject of an earlier post in this notebook.) Every spin still costs one thirty-seventh of the stake, and no arrangement of stakes, moods or stopping points changes the sum.
He found this out again on his honeymoon. Fleeing his creditors, the couple went abroad in 1867 and spent five weeks in Baden-Baden, where he quarrelled with Turgenev and lost heavily at the tables. Anna pawned her valuables and, by one account, even her clothes, and kept a diary of those weeks. The travels went on for four years, through Homburg, Saxon-les-Bains and Wiesbaden again.

In The Gambler he had already written the ending. An old grandmother arrives at the casino rich, wins at once, and in three days loses more than a hundred thousand roubles.
The One Who Beat the House
In April 1871 Dostoevsky made a last visit to the casino in Wiesbaden, and after it he gave up gambling. Anna tied it to the birth of their second daughter; biographers still argue about why.
Back in St Petersburg, Anna took over everything to do with money: the publishing, the negotiations and the sales, which she ran from their own apartment — Demons among them. She freed him from debt. The stenographer he had hired to beat a deadline became his publisher.

Of everyone in this story — the novelist with his composure, Casanova with his sixth card, ten thousand simulated gamblers with their ladders — only one person had a system that won. Anna’s was to stop playing, and start publishing.
Sources
- The letters and dates: the standard biographies of Dostoevsky and of Anna Dostoevskaya.
- Casanova’s words: his memoirs, in the English translation on Project Gutenberg.
- The probability: J. L. Doob’s optional stopping theorem, and J. Ville’s 1939 thesis, which named the martingale.
Every number here is computed by the script archived with this post.
Interested in applying these ideas to your work? Get in touch.