Skip to content

Instantly share code, notes, and snippets.

@lykkin
Created February 13, 2015 00:42
Show Gist options
  • Save lykkin/c20db3f6a1d128e40d46 to your computer and use it in GitHub Desktop.
Save lykkin/c20db3f6a1d128e40d46 to your computer and use it in GitHub Desktop.
from random import random
value = 0
acc = 0
payout = 2
for n in xrange(1, 1000001):
for x in xrange(10000000):
if random() <= .5:
value += payout
payout = 2
break
else:
payout *= 2
acc *= n-1
acc += float(value)
acc /= n
print acc/1000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment