I am struggling with overflow in my code and want to find a simple modification in such a way that overflow is minimized when trying to evaluate binomial coefficient for large n- and k values close to each other.
code:
def binomial_float(n, i):
p = 1; q = 1
for k in range(1, i+1):
p *= (n-k+1)/k #could I modify something here for instance?
return p
print(binomial_float(100000, 99940))
"""
Output:
inf #overflow
"""