I use this code:
import scipy.misc
import math
from decimal import Decimal
def n_choose_k(N, k, N2, k2, s):
if k > N:
return 0
a1 = Decimal.from_float(math.factorial(N))
a2 = Decimal.from_float(math.factorial(k))
a3 = Decimal.from_float(math.factorial(N-k))
a4 = Decimal.from_float(math.factorial(N2))
a5 = Decimal.from_float(math.factorial(k2))
a6 = Decimal.from_float(math.factorial(N2-k2))
a7 = Decimal.from_float(s)
rez = Decimal.from_float(0)
rez = (-1)**a7 * (a1/(a2*a3)) * (a4/(a5*a6))
return rez
accum = 0
for s in range(0, 101):
accum += n_choose_k(30+s,s,100,100-s,s)
Answer:
-10148107944337512107223500
But it is wrong answer.
If i use scipy.misc.comb
, then answer:
7075575608218126046195672175200960512
Ii's very right answer, but not presicion.
Please help.
question from:
https://stackoverflow.com/questions/66058590/calculate-the-sum-of-large-numbers-on-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…