Martingale-Bet

bet, capital = 1, c0
while true:
    bet = 2*bet
    r = Bernoulli(p)
    if r == 1:
        capital = capital - bet
    else:
        capital = capital + bet
    end
end