def return Decimal factorial Decimal factorial n-k factorial map Decim

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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)
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(n, 1025) for n in map(Decimal, xrange(1025, 2500))])
print 1 - all