% Bet until you pull ahead.

p=18/37 % Probability of winning (in Europe)


fortune=0
bet=1

while fortune<=0
    win=rand<p
    if win
        fortune=fortune+bet
    else
        fortune=fortune-bet
    end
end