from math import factorial from decimal import getcontext prec 100 def

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
from math import factorial
from decimal import *
getcontext().prec = 100
def C(n, k):
return Decimal(factorial(n)) / Decimal((factorial(n-k) * factorial(k)))
H = map(Decimal, range(1025))
d_3 = Decimal(3)
d_1 = Decimal(1.0)
c = C(n, 1025)
def tp(n):
m = Decimal(1)
for i in H:
m *= (n/d_3 - i) * d_1 / (n-i) * (n-((n/d_3)-i)) / (n-i)
return n
all = sum([tp(n) * c for n in map(Decimal, xrange(1025, 2500))])
print 1 - all