|
|
scott <sco### [at] scottcom> wrote:
> A game is played by repeatedly tossing a coin until it lands heads. If it
> lands heads on the first try, you win $1 and the game is over. If it lands
> heads on the 2nd try, you win $2 and the game is over. On the 3rd try $4,
> and in general if you get the head on the nth try, you win $2^(n-1).
> I simulated this game in C++ and after 1e6 goes the average win-per-go
> settles down quite nicely to $8.09 and stays there up to 1e8 goes.
How did you implement it? What type of integers did you use to count the
amount of money? (Note that a 32-bit integer will overflow after only 32
tosses of the coin, which is perfectly within the realm of possibility.)
--
- Warp
Post a reply to this message
|
|